2010-10-12 15:59:00 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-30 12:23:25 +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 23:16:46 +00:00
|
|
|
|
|
|
|
#define SC_RANGELST_CXX //fuer ICC
|
|
|
|
|
|
|
|
#include <stdlib.h> // qsort
|
2012-01-02 10:55:27 +00:00
|
|
|
#include <comphelper/string.hxx>
|
2001-03-14 15:02:54 +00:00
|
|
|
#include <unotools/collatorwrapper.hxx>
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
#include "rangelst.hxx"
|
|
|
|
#include "document.hxx"
|
|
|
|
#include "refupdat.hxx"
|
|
|
|
#include "rechead.hxx"
|
2009-12-05 11:07:21 -05:00
|
|
|
#include "compiler.hxx"
|
2011-06-07 17:09:21 -04:00
|
|
|
#include "stlalgorithm.hxx"
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2010-12-09 20:07:11 -05:00
|
|
|
using ::std::vector;
|
|
|
|
using ::std::advance;
|
2010-12-09 20:25:50 -05:00
|
|
|
using ::std::find_if;
|
2010-12-09 20:58:11 -05:00
|
|
|
using ::std::for_each;
|
2010-12-10 13:11:18 -05:00
|
|
|
using ::formula::FormulaGrammar;
|
2010-12-09 20:07:11 -05:00
|
|
|
|
2010-12-10 11:50:53 -05:00
|
|
|
namespace {
|
|
|
|
|
2010-12-10 12:21:14 -05:00
|
|
|
template<typename T>
|
2012-09-13 23:03:38 -04:00
|
|
|
class FindEnclosingRange : public ::std::unary_function<ScRange*, bool>
|
2010-12-10 12:21:14 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
FindEnclosingRange(const T& rTest) : mrTest(rTest) {}
|
|
|
|
FindEnclosingRange(const FindEnclosingRange& r) : mrTest(r.mrTest) {}
|
|
|
|
bool operator() (const ScRange* pRange) const
|
|
|
|
{
|
|
|
|
return pRange->In(mrTest);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
const T& mrTest;
|
|
|
|
};
|
|
|
|
|
2012-08-31 03:59:51 +02:00
|
|
|
template<typename T>
|
2012-09-13 23:03:38 -04:00
|
|
|
class FindRangeIn : public ::std::unary_function<ScRange*, bool>
|
2012-08-31 03:59:51 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
FindRangeIn(const T& rTest) : mrTest(rTest) {}
|
|
|
|
FindRangeIn(const FindRangeIn& r) : mrTest(r.mrTest) {}
|
|
|
|
bool operator() (const ScRange* pRange) const
|
|
|
|
{
|
|
|
|
return mrTest.In(*pRange);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
const T& mrTest;
|
|
|
|
};
|
|
|
|
|
2010-12-10 12:21:14 -05:00
|
|
|
template<typename T>
|
2012-09-13 23:03:38 -04:00
|
|
|
class FindIntersectingRange : public ::std::unary_function<ScRange*, bool>
|
2010-12-10 11:50:53 -05:00
|
|
|
{
|
|
|
|
public:
|
2010-12-10 12:21:14 -05:00
|
|
|
FindIntersectingRange(const T& rTest) : mrTest(rTest) {}
|
|
|
|
FindIntersectingRange(const FindIntersectingRange& r) : mrTest(r.mrTest) {}
|
2010-12-10 11:50:53 -05:00
|
|
|
bool operator() (const ScRange* pRange) const
|
|
|
|
{
|
2010-12-10 12:21:14 -05:00
|
|
|
return pRange->Intersects(mrTest);
|
2010-12-10 11:50:53 -05:00
|
|
|
}
|
|
|
|
private:
|
2010-12-10 12:21:14 -05:00
|
|
|
const T& mrTest;
|
2010-12-10 11:50:53 -05:00
|
|
|
};
|
|
|
|
|
2012-09-13 23:03:38 -04:00
|
|
|
class AppendToList : public ::std::unary_function<const ScRange*, void>
|
2010-12-10 12:06:57 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
AppendToList(vector<ScRange*>& rRanges) : mrRanges(rRanges) {}
|
|
|
|
AppendToList(const AppendToList& r) : mrRanges(r.mrRanges) {}
|
|
|
|
void operator() (const ScRange* p)
|
|
|
|
{
|
|
|
|
mrRanges.push_back(new ScRange(*p));
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
vector<ScRange*>& mrRanges;
|
|
|
|
};
|
|
|
|
|
2012-09-13 23:03:38 -04:00
|
|
|
class CountCells : public ::std::unary_function<const ScRange*, void>
|
2010-12-10 12:31:10 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
CountCells() : mnCellCount(0) {}
|
|
|
|
CountCells(const CountCells& r) : mnCellCount(r.mnCellCount) {}
|
|
|
|
|
|
|
|
void operator() (const ScRange* p)
|
|
|
|
{
|
|
|
|
mnCellCount +=
|
|
|
|
size_t(p->aEnd.Col() - p->aStart.Col() + 1)
|
|
|
|
* size_t(p->aEnd.Row() - p->aStart.Row() + 1)
|
|
|
|
* size_t(p->aEnd.Tab() - p->aStart.Tab() + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t getCellCount() const { return mnCellCount; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
size_t mnCellCount;
|
|
|
|
};
|
|
|
|
|
2012-09-13 23:03:38 -04:00
|
|
|
class FormatString : public ::std::unary_function<const ScRange*, void>
|
2010-12-10 13:11:18 -05:00
|
|
|
{
|
|
|
|
public:
|
2011-03-10 16:55:21 -05:00
|
|
|
FormatString(String& rStr, sal_uInt16 nFlags, ScDocument* pDoc, FormulaGrammar::AddressConvention eConv, sal_Unicode cDelim) :
|
2010-12-10 13:11:18 -05:00
|
|
|
mrStr(rStr),
|
|
|
|
mnFlags(nFlags),
|
|
|
|
mpDoc(pDoc),
|
|
|
|
meConv(eConv),
|
|
|
|
mcDelim(cDelim),
|
|
|
|
mbFirst(true) {}
|
|
|
|
|
|
|
|
FormatString(const FormatString& r) :
|
|
|
|
mrStr(r.mrStr),
|
|
|
|
mnFlags(r.mnFlags),
|
|
|
|
mpDoc(r.mpDoc),
|
|
|
|
meConv(r.meConv),
|
|
|
|
mcDelim(r.mcDelim),
|
|
|
|
mbFirst(r.mbFirst) {}
|
|
|
|
|
|
|
|
void operator() (const ScRange* p)
|
|
|
|
{
|
|
|
|
String aStr;
|
|
|
|
p->Format(aStr, mnFlags, mpDoc, meConv);
|
|
|
|
if (mbFirst)
|
|
|
|
mbFirst = false;
|
|
|
|
else
|
|
|
|
mrStr += mcDelim;
|
|
|
|
mrStr += aStr;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
String& mrStr;
|
2011-03-10 16:55:21 -05:00
|
|
|
sal_uInt16 mnFlags;
|
2010-12-10 13:11:18 -05:00
|
|
|
ScDocument* mpDoc;
|
|
|
|
FormulaGrammar::AddressConvention meConv;
|
|
|
|
sal_Unicode mcDelim;
|
|
|
|
bool mbFirst;
|
|
|
|
};
|
|
|
|
|
2012-09-13 23:03:38 -04:00
|
|
|
class FindDeletedRange : public ::std::unary_function<const ScRange*, bool>
|
2012-07-24 08:54:58 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
FindDeletedRange( SCsCOL nDx, SCsROW nDy): mnDx(nDx), mnDy(nDy) {}
|
|
|
|
FindDeletedRange( const FindDeletedRange& r) : mnDx(r.mnDx), mnDy(r.mnDy) {}
|
|
|
|
bool operator() (const ScRange* p)
|
|
|
|
{
|
2012-09-13 23:03:38 -04:00
|
|
|
const ScAddress& rStart = p->aStart;
|
|
|
|
const ScAddress& rEnd = p->aEnd;
|
2012-07-24 08:54:58 +02:00
|
|
|
|
|
|
|
if( rEnd.Col() +mnDx < rStart.Col() )
|
|
|
|
return true;
|
|
|
|
if( rEnd.Row() + mnDy < rStart.Row() )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
SCsCOL mnDx;
|
|
|
|
SCsROW mnDy;
|
|
|
|
};
|
|
|
|
|
2010-12-10 11:50:53 -05:00
|
|
|
}
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
// === ScRangeList ====================================================
|
|
|
|
|
|
|
|
ScRangeList::~ScRangeList()
|
|
|
|
{
|
2010-12-09 20:58:11 -05:00
|
|
|
RemoveAll();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 ScRangeList::Parse( const String& rStr, ScDocument* pDoc, sal_uInt16 nMask,
|
CWS-TOOLING: integrate CWS frmdlg
2008-12-18 09:13:09 +0100 oj r265667 : merge from odff05
2008-12-18 07:58:16 +0100 oj r265658 : #i94555# patch from <regina>, ODFF:
Add GAMMA, CHISQDIST, CHISQINV.
Make the 'cumulative' parameter of GAMMADIST optional.
Adapt the domain of CHIDIST to allow negative x.
Remove the constraint "degrees of freedom < 1.0E5" from CHIDIST and CHIINV.
Plus a mechanism to write the now optional parameter of GAMMADIST to PODF and
ODFF if omitted, for backwards compatibility.
2008-12-15 14:06:11 +0100 oj r265490 : CWS-TOOLING: rebase CWS frmdlg to trunk@264807 (milestone: DEV300:m37)
2008-12-15 13:55:28 +0100 oj r265488 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:55:07 +0100 oj r265487 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:48 +0100 oj r265486 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:36 +0100 oj r265485 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:24 +0100 oj r265484 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:48:11 +0100 oj r265483 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:31:12 +0100 oj r265479 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:13:58 +0100 oj r265477 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:10:09 +0100 oj r265476 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:05:11 +0100 oj r265475 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:47:17 +0100 oj r265467 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:46:19 +0100 oj r265466 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:45:47 +0100 oj r265465 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 07:35:07 +0100 oj r265458 : add dependency to formula
2008-12-15 07:34:24 +0100 oj r265457 : add dependency to formula
2008-12-12 13:22:00 +0100 msc r265413 : #i97089#
2008-12-12 13:20:25 +0100 msc r265412 : #i97089#
2008-12-12 12:35:12 +0100 msc r265406 : #i97089#
2008-12-12 12:34:16 +0100 msc r265405 : #i97089#
2008-12-12 12:33:05 +0100 msc r265404 : #i97089#
2008-12-12 12:31:11 +0100 msc r265403 : #i97089#
2008-12-08 11:59:10 +0100 oj r264981 : insert RTL_LOG
2008-12-08 11:50:17 +0100 oj r264980 : some small changes
2008-12-05 12:57:57 +0100 oj r264902 : eof changed
2008-12-05 12:56:46 +0100 oj r264901 : eof changed
2008-12-05 12:28:47 +0100 oj r264899 : wrong var used
2008-12-05 10:08:57 +0100 oj r264890 : token order reversed
2008-12-04 13:49:22 +0100 oc r264843 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:45:27 +0100 oc r264842 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:42:54 +0100 oc r264841 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:37:41 +0100 oc r264840 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:34:11 +0100 oc r264839 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 12:35:31 +0100 oj r264835 : new help ids for struct and function tabpage
2008-12-04 12:00:35 +0100 oj r264828 : set explicit help id
2008-12-03 14:53:27 +0100 oj r264786 : #i96845# change ref button
2008-12-03 14:51:49 +0100 oj r264785 : #i96845# change ref button
2008-12-03 08:51:57 +0100 oj r264746 : convert dos to unix lineends
2008-12-03 08:50:45 +0100 oj r264745 : convert dos to unix lineends
2008-12-03 08:50:05 +0100 oj r264744 : convert dos to unix lineends
2008-12-02 12:28:33 +0100 oj r264686 : clear help text when new helpid is set
2008-12-02 12:28:02 +0100 oj r264685 : set help id for listbox category
2008-12-02 07:15:56 +0100 oj r264655 : remove define to auto generate help ids
2008-12-01 14:36:43 +0100 oj r264604 : use temp var
2008-12-01 14:18:31 +0100 oj r264601 : moved ScJumpToken to formula
2008-12-01 14:18:11 +0100 oj r264600 : moved ScJumpToken to formula
2008-12-01 14:14:35 +0100 oj r264599 : moved ScJumpToken from sc
2008-12-01 10:48:51 +0100 oj r264589 : change quickhelptext from Shrink to Select
2008-12-01 10:28:41 +0100 oj r264588 : fix opcode data, has to be Any.Void
2008-11-28 11:16:48 +0100 oj r264532 : add help ids
2008-11-28 10:16:56 +0100 oj r264529 : set help id
2008-11-28 10:16:43 +0100 oj r264528 : set help id
2008-11-26 13:55:04 +0100 oj r264381 : #94535# use of optional instead of deleting a string myself and some small changes
2008-11-26 09:53:20 +0100 oj r264346 : compile error with debug/without debug
2008-11-25 07:41:28 +0100 oj r264271 : put static into the method which make use of them
2008-11-24 08:16:07 +0100 oj r264196 : removed not needed classes for op code
2008-11-24 08:13:44 +0100 oj r264195 : removed not needed classes for op code
2008-11-21 14:05:53 +0100 oj r264135 : make GetOpCode inline
2008-11-21 12:35:27 +0100 oj r264124 : hold symbols
2008-11-20 09:27:27 +0100 oj r264028 : merged code from DEV300_m35 which got lost
2008-11-19 20:42:12 +0100 oj r264022 : more changes for formula dialog remove
2008-11-19 20:37:41 +0100 oj r264021 : removed unused var
2008-11-19 20:35:35 +0100 oj r264020 : some more changes at token
2008-11-19 10:59:47 +0100 oj r263967 : deleted
2008-11-19 10:58:24 +0100 oj r263966 : add forui and for res files
2008-11-18 15:27:36 +0100 oj r263777 : unused para removed
2008-11-18 15:23:23 +0100 oj r263775 : add insert button to add field dlg
2008-11-18 13:39:53 +0100 oj r263764 : enable the formula dialog as well for conditional print as for conditional formatting
2008-11-18 12:03:25 +0100 oj r263760 : rename isRef in IsRef
2008-11-17 11:46:16 +0100 oj r263711 : patches for function handling
2008-11-17 11:36:22 +0100 oj r263710 : add new for forui and res file
2008-11-17 09:21:12 +0100 oj r263704 : patches for some resource for libformula
2008-11-15 12:45:30 +0100 oj r263701 : changes for formula editor extraction
2008-11-07 08:23:27 +0100 oj r263416 : merge from DEV300:m35
2008-11-07 08:22:35 +0100 oj r263415 : merge from DEV300:m35
2008-11-07 08:22:16 +0100 oj r263414 : merge from DEV300:m35
2008-11-07 08:21:41 +0100 oj r263413 : merge from DEV300:m35
2008-11-07 08:21:31 +0100 oj r263412 : merge from DEV300:m35
2008-11-07 08:20:38 +0100 oj r263411 : merge from DEV300:m35
2008-11-07 08:20:00 +0100 oj r263410 : merge from DEV300:m35
2008-11-07 08:18:50 +0100 oj r263409 : merge from DEV300:m35
2008-11-07 08:18:19 +0100 oj r263408 : merge from DEV300:m35
2008-11-07 08:10:27 +0100 oj r263407 : merge from DEV300:m35
2008-10-21 07:43:46 +0200 oj r262560 : some compile errors resolved
2008-10-17 16:40:01 +0200 oj r262291 : dep for 1st target
2008-10-07 10:08:39 +0200 oj r262077 : copy
2008-10-07 09:45:31 +0200 oj r262076 : #i94535#
2008-10-07 09:44:26 +0200 oj r262075 : #i94535# new base class
2008-10-07 09:43:21 +0200 oj r262074 : moved to formula
2008-10-07 09:41:51 +0200 oj r262073 : new images
2008-10-07 09:03:01 +0200 oj r262072 : new ids for formula
2008-10-02 08:46:27 +0200 oj r262024 : #i94535# move the formula compiler to formula
2008-10-02 08:08:54 +0200 oj r262023 : #i94535#
2008-10-02 08:06:28 +0200 oj r262022 : #i94535#
2008-10-02 08:05:52 +0200 oj r262021 : #i94535#
2008-10-01 17:15:29 +0200 oj r262014 : #i94535#
2008-10-01 17:12:40 +0200 oj r262013 : new module formula
2008-10-01 17:04:55 +0200 oj r262012 : #i94535#
2008-10-01 16:49:03 +0200 oj r262010 : #i94535#
2008-10-01 16:46:59 +0200 oj r262009 : #i94535#
2009-01-08 10:47:13 +00:00
|
|
|
formula::FormulaGrammar::AddressConvention eConv,
|
2012-12-05 02:40:44 +01:00
|
|
|
SCTAB nDefaultTab )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if ( rStr.Len() )
|
|
|
|
{
|
2012-12-05 02:40:44 +01:00
|
|
|
sal_Unicode cDelimiter = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
|
2006-10-18 11:23:03 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
nMask |= SCA_VALID; // falls das jemand vergessen sollte
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nResult = (sal_uInt16)~0; // alle Bits setzen
|
2000-09-18 23:16:46 +00:00
|
|
|
ScRange aRange;
|
|
|
|
String aOne;
|
2004-06-04 09:38:10 +00:00
|
|
|
SCTAB nTab = 0;
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( pDoc )
|
|
|
|
{
|
2012-12-05 02:25:50 +01:00
|
|
|
nTab = nDefaultTab;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
nTab = 0;
|
2012-01-02 10:55:27 +00:00
|
|
|
sal_uInt16 nTCount = comphelper::string::getTokenCount(rStr, cDelimiter);
|
2011-01-17 13:20:22 +01:00
|
|
|
for ( sal_uInt16 i=0; i<nTCount; i++ )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2006-10-18 11:23:03 +00:00
|
|
|
aOne = rStr.GetToken( i, cDelimiter );
|
2000-09-18 23:16:46 +00:00
|
|
|
aRange.aStart.SetTab( nTab ); // Default Tab wenn nicht angegeben
|
2011-03-10 16:55:21 -05:00
|
|
|
sal_uInt16 nRes = aRange.ParseAny( aOne, pDoc, eConv );
|
|
|
|
sal_uInt16 nEndRangeBits = SCA_VALID_COL2 | SCA_VALID_ROW2 | SCA_VALID_TAB2;
|
|
|
|
sal_uInt16 nTmp1 = ( nRes & SCA_BITS );
|
|
|
|
sal_uInt16 nTmp2 = ( nRes & nEndRangeBits );
|
2010-10-06 10:15:43 +01:00
|
|
|
// If we have a valid single range with
|
|
|
|
// any of the address bits we are interested in
|
|
|
|
// set - set the equiv end range bits
|
|
|
|
if ( (nRes & SCA_VALID ) && nTmp1 && ( nTmp2 != nEndRangeBits ) )
|
|
|
|
nRes |= ( nTmp1 << 4 );
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( (nRes & nMask) == nMask )
|
|
|
|
Append( aRange );
|
|
|
|
nResult &= nRes; // alle gemeinsamen Bits bleiben erhalten
|
|
|
|
}
|
|
|
|
return nResult; // SCA_VALID gesetzt wenn alle ok
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
void ScRangeList::Format( String& rStr, sal_uInt16 nFlags, ScDocument* pDoc,
|
CWS-TOOLING: integrate CWS frmdlg
2008-12-18 09:13:09 +0100 oj r265667 : merge from odff05
2008-12-18 07:58:16 +0100 oj r265658 : #i94555# patch from <regina>, ODFF:
Add GAMMA, CHISQDIST, CHISQINV.
Make the 'cumulative' parameter of GAMMADIST optional.
Adapt the domain of CHIDIST to allow negative x.
Remove the constraint "degrees of freedom < 1.0E5" from CHIDIST and CHIINV.
Plus a mechanism to write the now optional parameter of GAMMADIST to PODF and
ODFF if omitted, for backwards compatibility.
2008-12-15 14:06:11 +0100 oj r265490 : CWS-TOOLING: rebase CWS frmdlg to trunk@264807 (milestone: DEV300:m37)
2008-12-15 13:55:28 +0100 oj r265488 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:55:07 +0100 oj r265487 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:48 +0100 oj r265486 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:36 +0100 oj r265485 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:24 +0100 oj r265484 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:48:11 +0100 oj r265483 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:31:12 +0100 oj r265479 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:13:58 +0100 oj r265477 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:10:09 +0100 oj r265476 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:05:11 +0100 oj r265475 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:47:17 +0100 oj r265467 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:46:19 +0100 oj r265466 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:45:47 +0100 oj r265465 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 07:35:07 +0100 oj r265458 : add dependency to formula
2008-12-15 07:34:24 +0100 oj r265457 : add dependency to formula
2008-12-12 13:22:00 +0100 msc r265413 : #i97089#
2008-12-12 13:20:25 +0100 msc r265412 : #i97089#
2008-12-12 12:35:12 +0100 msc r265406 : #i97089#
2008-12-12 12:34:16 +0100 msc r265405 : #i97089#
2008-12-12 12:33:05 +0100 msc r265404 : #i97089#
2008-12-12 12:31:11 +0100 msc r265403 : #i97089#
2008-12-08 11:59:10 +0100 oj r264981 : insert RTL_LOG
2008-12-08 11:50:17 +0100 oj r264980 : some small changes
2008-12-05 12:57:57 +0100 oj r264902 : eof changed
2008-12-05 12:56:46 +0100 oj r264901 : eof changed
2008-12-05 12:28:47 +0100 oj r264899 : wrong var used
2008-12-05 10:08:57 +0100 oj r264890 : token order reversed
2008-12-04 13:49:22 +0100 oc r264843 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:45:27 +0100 oc r264842 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:42:54 +0100 oc r264841 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:37:41 +0100 oc r264840 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:34:11 +0100 oc r264839 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 12:35:31 +0100 oj r264835 : new help ids for struct and function tabpage
2008-12-04 12:00:35 +0100 oj r264828 : set explicit help id
2008-12-03 14:53:27 +0100 oj r264786 : #i96845# change ref button
2008-12-03 14:51:49 +0100 oj r264785 : #i96845# change ref button
2008-12-03 08:51:57 +0100 oj r264746 : convert dos to unix lineends
2008-12-03 08:50:45 +0100 oj r264745 : convert dos to unix lineends
2008-12-03 08:50:05 +0100 oj r264744 : convert dos to unix lineends
2008-12-02 12:28:33 +0100 oj r264686 : clear help text when new helpid is set
2008-12-02 12:28:02 +0100 oj r264685 : set help id for listbox category
2008-12-02 07:15:56 +0100 oj r264655 : remove define to auto generate help ids
2008-12-01 14:36:43 +0100 oj r264604 : use temp var
2008-12-01 14:18:31 +0100 oj r264601 : moved ScJumpToken to formula
2008-12-01 14:18:11 +0100 oj r264600 : moved ScJumpToken to formula
2008-12-01 14:14:35 +0100 oj r264599 : moved ScJumpToken from sc
2008-12-01 10:48:51 +0100 oj r264589 : change quickhelptext from Shrink to Select
2008-12-01 10:28:41 +0100 oj r264588 : fix opcode data, has to be Any.Void
2008-11-28 11:16:48 +0100 oj r264532 : add help ids
2008-11-28 10:16:56 +0100 oj r264529 : set help id
2008-11-28 10:16:43 +0100 oj r264528 : set help id
2008-11-26 13:55:04 +0100 oj r264381 : #94535# use of optional instead of deleting a string myself and some small changes
2008-11-26 09:53:20 +0100 oj r264346 : compile error with debug/without debug
2008-11-25 07:41:28 +0100 oj r264271 : put static into the method which make use of them
2008-11-24 08:16:07 +0100 oj r264196 : removed not needed classes for op code
2008-11-24 08:13:44 +0100 oj r264195 : removed not needed classes for op code
2008-11-21 14:05:53 +0100 oj r264135 : make GetOpCode inline
2008-11-21 12:35:27 +0100 oj r264124 : hold symbols
2008-11-20 09:27:27 +0100 oj r264028 : merged code from DEV300_m35 which got lost
2008-11-19 20:42:12 +0100 oj r264022 : more changes for formula dialog remove
2008-11-19 20:37:41 +0100 oj r264021 : removed unused var
2008-11-19 20:35:35 +0100 oj r264020 : some more changes at token
2008-11-19 10:59:47 +0100 oj r263967 : deleted
2008-11-19 10:58:24 +0100 oj r263966 : add forui and for res files
2008-11-18 15:27:36 +0100 oj r263777 : unused para removed
2008-11-18 15:23:23 +0100 oj r263775 : add insert button to add field dlg
2008-11-18 13:39:53 +0100 oj r263764 : enable the formula dialog as well for conditional print as for conditional formatting
2008-11-18 12:03:25 +0100 oj r263760 : rename isRef in IsRef
2008-11-17 11:46:16 +0100 oj r263711 : patches for function handling
2008-11-17 11:36:22 +0100 oj r263710 : add new for forui and res file
2008-11-17 09:21:12 +0100 oj r263704 : patches for some resource for libformula
2008-11-15 12:45:30 +0100 oj r263701 : changes for formula editor extraction
2008-11-07 08:23:27 +0100 oj r263416 : merge from DEV300:m35
2008-11-07 08:22:35 +0100 oj r263415 : merge from DEV300:m35
2008-11-07 08:22:16 +0100 oj r263414 : merge from DEV300:m35
2008-11-07 08:21:41 +0100 oj r263413 : merge from DEV300:m35
2008-11-07 08:21:31 +0100 oj r263412 : merge from DEV300:m35
2008-11-07 08:20:38 +0100 oj r263411 : merge from DEV300:m35
2008-11-07 08:20:00 +0100 oj r263410 : merge from DEV300:m35
2008-11-07 08:18:50 +0100 oj r263409 : merge from DEV300:m35
2008-11-07 08:18:19 +0100 oj r263408 : merge from DEV300:m35
2008-11-07 08:10:27 +0100 oj r263407 : merge from DEV300:m35
2008-10-21 07:43:46 +0200 oj r262560 : some compile errors resolved
2008-10-17 16:40:01 +0200 oj r262291 : dep for 1st target
2008-10-07 10:08:39 +0200 oj r262077 : copy
2008-10-07 09:45:31 +0200 oj r262076 : #i94535#
2008-10-07 09:44:26 +0200 oj r262075 : #i94535# new base class
2008-10-07 09:43:21 +0200 oj r262074 : moved to formula
2008-10-07 09:41:51 +0200 oj r262073 : new images
2008-10-07 09:03:01 +0200 oj r262072 : new ids for formula
2008-10-02 08:46:27 +0200 oj r262024 : #i94535# move the formula compiler to formula
2008-10-02 08:08:54 +0200 oj r262023 : #i94535#
2008-10-02 08:06:28 +0200 oj r262022 : #i94535#
2008-10-02 08:05:52 +0200 oj r262021 : #i94535#
2008-10-01 17:15:29 +0200 oj r262014 : #i94535#
2008-10-01 17:12:40 +0200 oj r262013 : new module formula
2008-10-01 17:04:55 +0200 oj r262012 : #i94535#
2008-10-01 16:49:03 +0200 oj r262010 : #i94535#
2008-10-01 16:46:59 +0200 oj r262009 : #i94535#
2009-01-08 10:47:13 +00:00
|
|
|
formula::FormulaGrammar::AddressConvention eConv,
|
2009-12-05 11:07:21 -05:00
|
|
|
sal_Unicode cDelimiter ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
rStr.Erase();
|
2006-10-18 11:23:03 +00:00
|
|
|
|
2009-12-05 11:07:21 -05:00
|
|
|
if (!cDelimiter)
|
|
|
|
cDelimiter = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
|
2006-10-18 11:23:03 +00:00
|
|
|
|
2010-12-10 13:11:18 -05:00
|
|
|
FormatString func(rStr, nFlags, pDoc, eConv, cDelimiter);
|
|
|
|
for_each(maRanges.begin(), maRanges.end(), func);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-06 18:11:43 +01:00
|
|
|
void ScRangeList::Format( rtl::OUString& rStr, sal_uInt16 nFlags, ScDocument* pDoc,
|
|
|
|
formula::FormulaGrammar::AddressConvention eConv,
|
|
|
|
sal_Unicode cDelimiter ) const
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!cDelimiter)
|
|
|
|
cDelimiter = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
|
|
|
|
|
|
|
|
String aStr;
|
|
|
|
FormatString func(aStr, nFlags, pDoc, eConv, cDelimiter);
|
|
|
|
for_each(maRanges.begin(), maRanges.end(), func);
|
|
|
|
rStr = aStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 22:38:24 -08:00
|
|
|
void ScRangeList::Join( const ScRange& r, bool bIsInList )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-12-09 20:07:11 -05:00
|
|
|
if ( maRanges.empty() )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
Append( r );
|
|
|
|
return ;
|
|
|
|
}
|
2004-06-04 09:38:10 +00:00
|
|
|
SCCOL nCol1 = r.aStart.Col();
|
|
|
|
SCROW nRow1 = r.aStart.Row();
|
|
|
|
SCTAB nTab1 = r.aStart.Tab();
|
|
|
|
SCCOL nCol2 = r.aEnd.Col();
|
|
|
|
SCROW nRow2 = r.aEnd.Row();
|
|
|
|
SCTAB nTab2 = r.aEnd.Tab();
|
2010-12-08 22:38:24 -08:00
|
|
|
|
2010-12-09 20:07:11 -05:00
|
|
|
ScRange* pOver = (ScRange*) &r; // fies aber wahr wenn bInList
|
2010-12-08 22:38:24 -08:00
|
|
|
size_t nOldPos = 0;
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( bIsInList )
|
2010-12-09 20:07:11 -05:00
|
|
|
{
|
|
|
|
// Find the current position of this range.
|
|
|
|
for ( size_t i = 0, nRanges = maRanges.size(); i < nRanges; ++i )
|
2010-12-08 22:38:24 -08:00
|
|
|
{
|
2010-12-09 20:07:11 -05:00
|
|
|
if ( maRanges[i] == pOver )
|
2010-12-08 22:38:24 -08:00
|
|
|
{
|
|
|
|
nOldPos = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-12-08 22:38:24 -08:00
|
|
|
bool bJoinedInput = false;
|
|
|
|
|
2011-05-24 15:49:55 -04:00
|
|
|
// We need to query the size of the container dynamically since its size
|
|
|
|
// may change during the loop.
|
|
|
|
for ( size_t i = 0; i < maRanges.size() && pOver; ++i )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-12-09 20:07:11 -05:00
|
|
|
ScRange* p = maRanges[i];
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( p == pOver )
|
|
|
|
continue; // derselbe, weiter mit dem naechsten
|
2010-12-08 22:38:24 -08:00
|
|
|
bool bJoined = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( p->In( r ) )
|
|
|
|
{ // Range r in Range p enthalten oder identisch
|
|
|
|
if ( bIsInList )
|
2010-12-08 22:38:24 -08:00
|
|
|
bJoined = true; // weg mit Range r
|
2000-09-18 23:16:46 +00:00
|
|
|
else
|
|
|
|
{ // das war's dann
|
2010-12-08 22:38:24 -08:00
|
|
|
bJoinedInput = true; // nicht anhaengen
|
2000-09-18 23:16:46 +00:00
|
|
|
break; // for
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( r.In( *p ) )
|
|
|
|
{ // Range p in Range r enthalten, r zum neuen Range machen
|
|
|
|
*p = r;
|
2010-12-08 22:38:24 -08:00
|
|
|
bJoined = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
if ( !bJoined && p->aStart.Tab() == nTab1 && p->aEnd.Tab() == nTab2 )
|
|
|
|
{ // 2D
|
|
|
|
if ( p->aStart.Col() == nCol1 && p->aEnd.Col() == nCol2 )
|
|
|
|
{
|
|
|
|
if ( p->aStart.Row() == nRow2+1 )
|
|
|
|
{ // oben
|
|
|
|
p->aStart.SetRow( nRow1 );
|
2010-12-08 22:38:24 -08:00
|
|
|
bJoined = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else if ( p->aEnd.Row() == nRow1-1 )
|
|
|
|
{ // unten
|
|
|
|
p->aEnd.SetRow( nRow2 );
|
2010-12-08 22:38:24 -08:00
|
|
|
bJoined = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( p->aStart.Row() == nRow1 && p->aEnd.Row() == nRow2 )
|
|
|
|
{
|
|
|
|
if ( p->aStart.Col() == nCol2+1 )
|
|
|
|
{ // links
|
|
|
|
p->aStart.SetCol( nCol1 );
|
2010-12-08 22:38:24 -08:00
|
|
|
bJoined = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else if ( p->aEnd.Col() == nCol1-1 )
|
|
|
|
{ // rechts
|
|
|
|
p->aEnd.SetCol( nCol2 );
|
2010-12-08 22:38:24 -08:00
|
|
|
bJoined = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( bJoined )
|
|
|
|
{
|
|
|
|
if ( bIsInList )
|
|
|
|
{ // innerhalb der Liste Range loeschen
|
2010-12-09 20:07:11 -05:00
|
|
|
Remove(nOldPos);
|
2011-05-25 01:21:30 +02:00
|
|
|
i--;
|
2010-12-09 18:50:56 -05:00
|
|
|
delete pOver;
|
2000-09-18 23:16:46 +00:00
|
|
|
pOver = NULL;
|
|
|
|
if ( nOldPos )
|
|
|
|
nOldPos--; // Seek richtig aufsetzen
|
|
|
|
}
|
2010-12-08 22:38:24 -08:00
|
|
|
bJoinedInput = true;
|
|
|
|
Join( *p, true ); // rekursiv!
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
2010-12-08 22:38:24 -08:00
|
|
|
if ( !bIsInList && !bJoinedInput )
|
2000-09-18 23:16:46 +00:00
|
|
|
Append( r );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 22:38:24 -08:00
|
|
|
bool ScRangeList::operator==( const ScRangeList& r ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if ( this == &r )
|
2010-12-10 11:50:53 -05:00
|
|
|
return true;
|
|
|
|
|
|
|
|
if (maRanges.size() != r.maRanges.size())
|
2010-12-08 22:38:24 -08:00
|
|
|
return false;
|
2010-12-10 11:50:53 -05:00
|
|
|
|
|
|
|
vector<ScRange*>::const_iterator itr1 = maRanges.begin(), itrEnd = maRanges.end();
|
|
|
|
vector<ScRange*>::const_iterator itr2 = r.maRanges.begin();
|
|
|
|
for (; itr1 != itrEnd; ++itr1, ++itr2)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-12-10 11:50:53 -05:00
|
|
|
const ScRange* p1 = *itr1;
|
|
|
|
const ScRange* p2 = *itr2;
|
|
|
|
if (*p1 != *p2)
|
|
|
|
return false;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-12-08 22:38:24 -08:00
|
|
|
return true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2010-12-08 22:38:24 -08:00
|
|
|
bool ScRangeList::operator!=( const ScRangeList& r ) const
|
2010-01-15 12:00:39 +01:00
|
|
|
{
|
|
|
|
return !operator==( r );
|
|
|
|
}
|
|
|
|
|
2010-12-08 22:38:24 -08:00
|
|
|
bool ScRangeList::UpdateReference(
|
|
|
|
UpdateRefMode eUpdateRefMode,
|
|
|
|
ScDocument* pDoc,
|
|
|
|
const ScRange& rWhere,
|
|
|
|
SCsCOL nDx,
|
|
|
|
SCsROW nDy,
|
|
|
|
SCsTAB nDz
|
|
|
|
)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-12-10 12:45:49 -05:00
|
|
|
if (maRanges.empty())
|
|
|
|
// No ranges to update. Bail out.
|
|
|
|
return false;
|
|
|
|
|
2010-12-10 12:34:54 -05:00
|
|
|
bool bChanged = false;
|
2010-12-10 12:45:49 -05:00
|
|
|
SCCOL nCol1;
|
|
|
|
SCROW nRow1;
|
|
|
|
SCTAB nTab1;
|
|
|
|
SCCOL nCol2;
|
|
|
|
SCROW nRow2;
|
|
|
|
SCTAB nTab2;
|
|
|
|
rWhere.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
|
|
|
|
|
2012-09-17 17:58:27 +02:00
|
|
|
if(eUpdateRefMode == URM_INSDEL)
|
|
|
|
{
|
|
|
|
// right now this only works for nTab1 == nTab2
|
|
|
|
if(nTab1 == nTab2)
|
|
|
|
{
|
|
|
|
if(nDx < 0)
|
|
|
|
{
|
2012-09-21 13:37:31 +02:00
|
|
|
DeleteArea(nCol1+nDx, nRow1, nTab1, nCol1-1, nRow2, nTab2);
|
2012-09-17 17:58:27 +02:00
|
|
|
}
|
|
|
|
if(nDy < 0)
|
|
|
|
{
|
2012-09-21 13:37:31 +02:00
|
|
|
DeleteArea(nCol1, nRow1+nDy, nTab1, nCol2, nRow1-1, nTab2);
|
2012-09-17 17:58:27 +02:00
|
|
|
}
|
|
|
|
SAL_WARN_IF(nDx < 0 && nDy < 0, "sc", "nDx and nDy are negative, check why");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-25 21:48:54 +02:00
|
|
|
if(maRanges.empty())
|
|
|
|
return true;
|
|
|
|
|
2012-09-18 02:25:19 +02:00
|
|
|
iterator itr = maRanges.begin(), itrEnd = maRanges.end();
|
2010-12-10 12:45:49 -05:00
|
|
|
for (; itr != itrEnd; ++itr)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-12-10 12:45:49 -05:00
|
|
|
ScRange* pR = *itr;
|
|
|
|
SCCOL theCol1;
|
|
|
|
SCROW theRow1;
|
|
|
|
SCTAB theTab1;
|
|
|
|
SCCOL theCol2;
|
|
|
|
SCROW theRow2;
|
|
|
|
SCTAB theTab2;
|
|
|
|
pR->GetVars( theCol1, theRow1, theTab1, theCol2, theRow2, theTab2 );
|
|
|
|
if ( ScRefUpdate::Update( pDoc, eUpdateRefMode,
|
|
|
|
nCol1, nRow1, nTab1, nCol2, nRow2, nTab2,
|
|
|
|
nDx, nDy, nDz,
|
|
|
|
theCol1, theRow1, theTab1, theCol2, theRow2, theTab2 )
|
|
|
|
!= UR_NOTHING )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-12-10 12:45:49 -05:00
|
|
|
bChanged = true;
|
|
|
|
pR->aStart.Set( theCol1, theRow1, theTab1 );
|
|
|
|
pR->aEnd.Set( theCol2, theRow2, theTab2 );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
2012-09-25 21:48:54 +02:00
|
|
|
|
|
|
|
if(eUpdateRefMode == URM_INSDEL)
|
|
|
|
{
|
|
|
|
if( nDx < 0 || nDy < 0 )
|
|
|
|
{
|
|
|
|
size_t n = maRanges.size();
|
2012-10-02 00:41:08 +02:00
|
|
|
Join(*maRanges[n-1], true);
|
2012-09-25 21:48:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
return bChanged;
|
|
|
|
}
|
|
|
|
|
2012-08-31 03:59:51 +02:00
|
|
|
namespace {
|
|
|
|
|
2012-09-21 15:12:40 -04:00
|
|
|
/**
|
|
|
|
* Check if the deleting range cuts the test range exactly into a single
|
|
|
|
* piece.
|
|
|
|
*
|
|
|
|
* X = column ; Y = row
|
|
|
|
* +------+ +------+
|
|
|
|
* |xxxxxx| | |
|
|
|
|
* +------+ or +------+
|
|
|
|
* | | |xxxxxx|
|
|
|
|
* +------+ +------+
|
|
|
|
*
|
|
|
|
* X = row; Y = column
|
|
|
|
* +--+--+ +--+--+
|
|
|
|
* |xx| | | |xx|
|
|
|
|
* |xx| | or | |xx|
|
|
|
|
* |xx| | | |xx|
|
|
|
|
* +--+--+ +--+--+
|
|
|
|
* where xxx is the deleted region.
|
|
|
|
*/
|
2012-08-31 03:59:51 +02:00
|
|
|
template<typename X, typename Y>
|
2012-09-21 15:12:40 -04:00
|
|
|
bool checkForOneRange(
|
|
|
|
X nDeleteX1, X nDeleteX2, Y nDeleteY1, Y nDeleteY2, X nX1, X nX2, Y nY1, Y nY2)
|
2012-08-31 03:59:51 +02:00
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
if (nDeleteX1 <= nX1 && nX2 <= nDeleteX2 && (nDeleteY1 <= nY1 || nY2 <= nDeleteY2))
|
2012-08-31 03:59:51 +02:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool handleOneRange( const ScRange& rDeleteRange, ScRange* p )
|
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
const ScAddress& rDelStart = rDeleteRange.aStart;
|
|
|
|
const ScAddress& rDelEnd = rDeleteRange.aEnd;
|
|
|
|
ScAddress aPStart = p->aStart;
|
|
|
|
ScAddress aPEnd = p->aEnd;
|
|
|
|
SCCOL nDeleteCol1 = rDelStart.Col();
|
|
|
|
SCCOL nDeleteCol2 = rDelEnd.Col();
|
|
|
|
SCROW nDeleteRow1 = rDelStart.Row();
|
|
|
|
SCROW nDeleteRow2 = rDelEnd.Row();
|
|
|
|
SCCOL nCol1 = aPStart.Col();
|
|
|
|
SCCOL nCol2 = aPEnd.Col();
|
|
|
|
SCROW nRow1 = aPStart.Row();
|
|
|
|
SCROW nRow2 = aPEnd.Row();
|
|
|
|
|
|
|
|
if (checkForOneRange(nDeleteCol1, nDeleteCol2, nDeleteRow1, nDeleteRow2, nCol1, nCol2, nRow1, nRow2))
|
2012-08-31 03:59:51 +02:00
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
// Deleting range fully overlaps the column range. Adjust the row span.
|
|
|
|
if (nDeleteRow1 <= nRow1)
|
2012-08-31 03:59:51 +02:00
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
// +------+
|
|
|
|
// |xxxxxx|
|
|
|
|
// +------+
|
|
|
|
// | |
|
|
|
|
// +------+ (xxx) = deleted region
|
|
|
|
|
|
|
|
p->aStart.SetRow(nDeleteRow1+1);
|
2012-09-21 20:20:18 -04:00
|
|
|
return true;
|
2012-08-31 03:59:51 +02:00
|
|
|
}
|
2012-09-21 15:12:40 -04:00
|
|
|
else if (nRow2 <= nDeleteRow2)
|
2012-08-31 03:59:51 +02:00
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
// +------+
|
|
|
|
// | |
|
|
|
|
// +------+
|
|
|
|
// |xxxxxx|
|
|
|
|
// +------+ (xxx) = deleted region
|
|
|
|
|
|
|
|
p->aEnd.SetRow(nDeleteRow1-1);
|
2012-09-21 20:20:18 -04:00
|
|
|
return true;
|
2012-08-31 03:59:51 +02:00
|
|
|
}
|
|
|
|
}
|
2012-09-21 15:12:40 -04:00
|
|
|
else if (checkForOneRange(nDeleteRow1, nDeleteRow2, nDeleteCol1, nDeleteCol2, nRow1, nRow2, nCol1, nCol2))
|
2012-08-31 03:59:51 +02:00
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
// Deleting range fully overlaps the row range. Adjust the column span.
|
|
|
|
if (nDeleteCol1 <= nCol1)
|
|
|
|
{
|
|
|
|
// +--+--+
|
|
|
|
// |xx| |
|
|
|
|
// |xx| |
|
|
|
|
// |xx| |
|
|
|
|
// +--+--+ (xxx) = deleted region
|
|
|
|
|
|
|
|
p->aStart.SetCol(nDeleteCol2+1);
|
2012-09-21 20:20:18 -04:00
|
|
|
return true;
|
2012-09-21 15:12:40 -04:00
|
|
|
}
|
|
|
|
else if (nCol2 <= nDeleteCol2)
|
|
|
|
{
|
|
|
|
// +--+--+
|
|
|
|
// | |xx|
|
|
|
|
// | |xx|
|
|
|
|
// | |xx|
|
|
|
|
// +--+--+ (xxx) = deleted region
|
|
|
|
|
|
|
|
p->aEnd.SetCol(nDeleteCol1-1);
|
2012-09-21 20:20:18 -04:00
|
|
|
return true;
|
2012-09-21 15:12:40 -04:00
|
|
|
}
|
2012-08-31 03:59:51 +02:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-09-21 15:12:40 -04:00
|
|
|
/**
|
|
|
|
* Check if the deleting range cuts the test range in the middle, to
|
|
|
|
* separate it into exactly two pieces.
|
|
|
|
*
|
|
|
|
* Either
|
|
|
|
* +--------+ +--+-+--+
|
|
|
|
* | | | |x| |
|
|
|
|
* +--------+ | |x| |
|
|
|
|
* |xxxxxxxx| or | |x| |
|
|
|
|
* +--------+ | |x| |
|
|
|
|
* | | | |x| |
|
|
|
|
* +--------+ +--+-+--+
|
|
|
|
* where xxx is the deleted region.
|
|
|
|
*/
|
2012-08-31 03:59:51 +02:00
|
|
|
template<typename X, typename Y>
|
2012-09-21 15:12:40 -04:00
|
|
|
bool checkForTwoRangesCase2(
|
|
|
|
X nDeleteX1, X nDeleteX2, Y nDeleteY1, Y nDeleteY2, X nX1, X nX2, Y nY1, Y nY2)
|
2012-08-31 03:59:51 +02:00
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
if (nY1 < nDeleteY1 && nDeleteY2 < nY2 && nDeleteX1 <= nX1 && nX2 <= nDeleteX2)
|
2012-08-31 03:59:51 +02:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool handleTwoRanges( const ScRange& rDeleteRange, ScRange* p, std::vector<ScRange>& rNewRanges )
|
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
const ScAddress& rDelStart = rDeleteRange.aStart;
|
|
|
|
const ScAddress& rDelEnd = rDeleteRange.aEnd;
|
|
|
|
ScAddress aPStart = p->aStart;
|
|
|
|
ScAddress aPEnd = p->aEnd;
|
|
|
|
SCCOL nDeleteCol1 = rDelStart.Col();
|
|
|
|
SCCOL nDeleteCol2 = rDelEnd.Col();
|
|
|
|
SCROW nDeleteRow1 = rDelStart.Row();
|
|
|
|
SCROW nDeleteRow2 = rDelEnd.Row();
|
|
|
|
SCCOL nCol1 = aPStart.Col();
|
|
|
|
SCCOL nCol2 = aPEnd.Col();
|
|
|
|
SCROW nRow1 = aPStart.Row();
|
|
|
|
SCROW nRow2 = aPEnd.Row();
|
|
|
|
SCTAB nTab = aPStart.Tab();
|
|
|
|
|
2012-09-21 20:20:18 -04:00
|
|
|
if (nCol1 < nDeleteCol1 && nDeleteCol1 <= nCol2 && nCol2 <= nDeleteCol2)
|
2012-08-31 03:59:51 +02:00
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
// column deleted : |-------|
|
|
|
|
// column original: |-------|
|
2012-09-22 04:44:35 +02:00
|
|
|
if (nRow1 < nDeleteRow1 && nDeleteRow1 <= nRow2 && nRow2 <= nDeleteRow2)
|
2012-08-31 03:59:51 +02:00
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
// row deleted: |------|
|
|
|
|
// row original: |------|
|
|
|
|
//
|
|
|
|
// +-------+
|
|
|
|
// | 1 |
|
|
|
|
// +---+---+---+
|
|
|
|
// | 2 |xxxxxxx|
|
|
|
|
// +---+xxxxxxx|
|
|
|
|
// |xxxxxxx|
|
|
|
|
// +-------+ (xxx) deleted region
|
|
|
|
|
|
|
|
ScRange aNewRange( nCol1, nDeleteRow1, nTab, nDeleteCol1-1, nRow2, nTab ); // 2
|
2012-08-31 03:59:51 +02:00
|
|
|
rNewRanges.push_back(aNewRange);
|
|
|
|
|
2012-09-21 15:12:40 -04:00
|
|
|
p->aEnd.SetRow(nDeleteRow1-1); // 1
|
2012-08-31 03:59:51 +02:00
|
|
|
return true;
|
|
|
|
}
|
2012-09-22 04:44:35 +02:00
|
|
|
else if (nRow1 <= nDeleteRow2 && nDeleteRow2 < nRow2 && nDeleteRow1 <= nRow1)
|
2012-08-31 03:59:51 +02:00
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
// row deleted: |------|
|
|
|
|
// row original: |------|
|
|
|
|
//
|
|
|
|
// +-------+
|
|
|
|
// |xxxxxxx|
|
|
|
|
// +---+xxxxxxx|
|
|
|
|
// | 1 |xxxxxxx|
|
|
|
|
// +---+---+---+
|
|
|
|
// | 2 | (xxx) deleted region
|
|
|
|
// +-------+
|
|
|
|
|
2012-09-21 20:20:18 -04:00
|
|
|
ScRange aNewRange( aPStart, ScAddress(nDeleteCol1-1, nRow2, nTab) ); // 1
|
2012-08-31 03:59:51 +02:00
|
|
|
rNewRanges.push_back(aNewRange);
|
|
|
|
|
2012-09-21 15:12:40 -04:00
|
|
|
p->aStart.SetRow(nDeleteRow2+1); // 2
|
2012-08-31 03:59:51 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2012-09-21 20:20:18 -04:00
|
|
|
else if (nCol1 <= nDeleteCol2 && nDeleteCol2 < nCol2 && nDeleteCol1 <= nCol1)
|
2012-08-31 03:59:51 +02:00
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
// column deleted : |-------|
|
|
|
|
// column original: |-------|
|
2012-09-22 04:44:35 +02:00
|
|
|
if (nRow1 < nDeleteRow1 && nDeleteRow1 <= nRow2 && nRow2 <= nDeleteRow2)
|
2012-08-31 03:59:51 +02:00
|
|
|
{
|
2012-09-21 20:20:18 -04:00
|
|
|
// row deleted: |------|
|
|
|
|
// row original: |------|
|
2012-09-21 15:12:40 -04:00
|
|
|
//
|
2012-09-21 20:20:18 -04:00
|
|
|
// +-------+
|
|
|
|
// | 1 |
|
|
|
|
// +-------+---+
|
|
|
|
// |xxxxxxx| 2 |
|
|
|
|
// |xxxxxxx+---+
|
|
|
|
// |xxxxxxx|
|
|
|
|
// +-------+
|
2012-09-21 15:12:40 -04:00
|
|
|
// (xxx) deleted region
|
|
|
|
|
|
|
|
ScRange aNewRange( ScAddress( nDeleteCol2+1, nDeleteRow1, nTab ), aPEnd ); // 2
|
2012-08-31 03:59:51 +02:00
|
|
|
rNewRanges.push_back(aNewRange);
|
|
|
|
|
2012-09-21 15:12:40 -04:00
|
|
|
p->aEnd.SetRow(nDeleteRow1-1); // 1
|
2012-08-31 03:59:51 +02:00
|
|
|
return true;
|
|
|
|
}
|
2012-09-22 04:44:35 +02:00
|
|
|
else if (nRow1 <= nDeleteRow2 && nDeleteRow2 < nRow2 && nDeleteRow1 <= nRow1)
|
2012-08-31 03:59:51 +02:00
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
// row deleted: |-------|
|
|
|
|
// row original: |--------|
|
|
|
|
//
|
|
|
|
// +-------+
|
|
|
|
// |xxxxxxx|
|
|
|
|
// |xxxxxxx+---+
|
|
|
|
// |xxxxxxx| 1 |
|
|
|
|
// +-------+---+
|
|
|
|
// | 2 |
|
|
|
|
// +-------+ (xxx) deleted region
|
|
|
|
|
2012-09-21 20:20:18 -04:00
|
|
|
ScRange aNewRange(nDeleteCol2+1, nRow1, nTab, nCol2, nDeleteRow2, nTab); // 1
|
2012-08-31 03:59:51 +02:00
|
|
|
rNewRanges.push_back(aNewRange);
|
|
|
|
|
2012-09-21 15:12:40 -04:00
|
|
|
p->aStart.SetRow(nDeleteRow2+1); // 2
|
2012-08-31 03:59:51 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2012-09-21 15:12:40 -04:00
|
|
|
else if (nRow1 < nDeleteRow1 && nDeleteRow2 < nRow2 && nDeleteCol1 <= nCol1 && nCol2 <= nDeleteCol2)
|
2012-08-31 03:59:51 +02:00
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
// +--------+
|
|
|
|
// | 1 |
|
|
|
|
// +--------+
|
|
|
|
// |xxxxxxxx| (xxx) deleted region
|
|
|
|
// +--------+
|
|
|
|
// | 2 |
|
|
|
|
// +--------+
|
|
|
|
|
|
|
|
ScRange aNewRange( aPStart, ScAddress(nCol2, nDeleteRow1-1, nTab) ); // 1
|
2012-08-31 03:59:51 +02:00
|
|
|
rNewRanges.push_back(aNewRange);
|
|
|
|
|
2012-09-21 15:12:40 -04:00
|
|
|
p->aStart.SetRow(nDeleteRow2+1); // 2
|
2012-08-31 03:59:51 +02:00
|
|
|
return true;
|
|
|
|
}
|
2012-09-21 15:12:40 -04:00
|
|
|
else if (nCol1 < nDeleteCol1 && nDeleteCol2 < nCol2 && nDeleteRow1 <= nRow1 && nRow2 <= nDeleteRow2)
|
2012-08-31 03:59:51 +02:00
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
// +---+-+---+
|
|
|
|
// | |x| |
|
|
|
|
// | |x| |
|
|
|
|
// | 1 |x| 2 | (xxx) deleted region
|
|
|
|
// | |x| |
|
|
|
|
// | |x| |
|
|
|
|
// +---+-+---+
|
|
|
|
|
|
|
|
ScRange aNewRange( aPStart, ScAddress(nDeleteCol1-1, nRow2, nTab) ); // 1
|
2012-08-31 03:59:51 +02:00
|
|
|
rNewRanges.push_back(aNewRange);
|
|
|
|
|
2012-09-21 15:12:40 -04:00
|
|
|
p->aStart.SetCol(nDeleteCol2+1); // 2
|
2012-08-31 03:59:51 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-09-21 15:12:40 -04:00
|
|
|
/**
|
|
|
|
* Check if any of the followings applies:
|
|
|
|
*
|
|
|
|
* X = column; Y = row
|
|
|
|
* +----------+ +----------+
|
|
|
|
* | | | |
|
|
|
|
* | +-------+---+ +--+-------+ |
|
|
|
|
* | |xxxxxxxxxxx| or |xxxxxxxxxx| |
|
|
|
|
* | +-------+---+ +--+-------+ |
|
|
|
|
* | | | |
|
|
|
|
* +----------+ +----------+
|
|
|
|
*
|
|
|
|
* X = row; Y = column
|
|
|
|
* +--+
|
|
|
|
* |xx|
|
|
|
|
* +---+xx+---+ +----------+
|
|
|
|
* | |xx| | | |
|
|
|
|
* | |xx| | or | +--+ |
|
|
|
|
* | +--+ | | |xx| |
|
|
|
|
* | | | |xx| |
|
|
|
|
* +----------+ +---+xx+---+
|
|
|
|
* |xx|
|
|
|
|
* +--+ (xxx) deleted region
|
|
|
|
*/
|
2012-08-31 03:59:51 +02:00
|
|
|
template<typename X, typename Y>
|
2012-09-21 15:12:40 -04:00
|
|
|
bool checkForThreeRanges(
|
|
|
|
X nDeleteX1, X nDeleteX2, Y nDeleteY1, Y nDeleteY2, X nX1, X nX2, Y nY1, Y nY2)
|
2012-08-31 03:59:51 +02:00
|
|
|
{
|
2012-09-22 04:44:35 +02:00
|
|
|
if (nX1 <= nDeleteX1 && nX2 <= nDeleteX2 && nY1 < nDeleteY1 && nDeleteY2 < nY2)
|
2012-08-31 03:59:51 +02:00
|
|
|
return true;
|
2012-09-21 15:12:40 -04:00
|
|
|
|
2012-09-22 04:44:35 +02:00
|
|
|
if (nDeleteX1 <= nX1 && nDeleteX2 <= nX2 && nY1 < nDeleteY1 && nDeleteY2 < nY2)
|
2012-08-31 03:59:51 +02:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool handleThreeRanges( const ScRange& rDeleteRange, ScRange* p, std::vector<ScRange>& rNewRanges )
|
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
const ScAddress& rDelStart = rDeleteRange.aStart;
|
|
|
|
const ScAddress& rDelEnd = rDeleteRange.aEnd;
|
|
|
|
ScAddress aPStart = p->aStart;
|
|
|
|
ScAddress aPEnd = p->aEnd;
|
|
|
|
SCCOL nDeleteCol1 = rDelStart.Col();
|
|
|
|
SCCOL nDeleteCol2 = rDelEnd.Col();
|
|
|
|
SCROW nDeleteRow1 = rDelStart.Row();
|
|
|
|
SCROW nDeleteRow2 = rDelEnd.Row();
|
|
|
|
SCCOL nCol1 = aPStart.Col();
|
|
|
|
SCCOL nCol2 = aPEnd.Col();
|
|
|
|
SCROW nRow1 = aPStart.Row();
|
|
|
|
SCROW nRow2 = aPEnd.Row();
|
|
|
|
SCTAB nTab = aPStart.Tab();
|
|
|
|
|
|
|
|
if (checkForThreeRanges(nDeleteCol1, nDeleteCol2, nDeleteRow1, nDeleteRow2, nCol1, nCol2, nRow1, nRow2))
|
2012-08-31 03:59:51 +02:00
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
if (nCol1 < nDeleteCol1)
|
2012-08-31 03:59:51 +02:00
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
// +---+------+
|
|
|
|
// | | 2 |
|
|
|
|
// | +------+---+
|
|
|
|
// | 1 |xxxxxxxxxx|
|
|
|
|
// | +------+---+
|
|
|
|
// | | 3 |
|
|
|
|
// +---+------+
|
|
|
|
|
|
|
|
ScRange aNewRange(nDeleteCol1, nRow1, nTab, nCol2, nDeleteRow1-1, nTab); // 2
|
2012-08-31 03:59:51 +02:00
|
|
|
rNewRanges.push_back(aNewRange);
|
|
|
|
|
2012-09-21 15:12:40 -04:00
|
|
|
aNewRange = ScRange(ScAddress(nDeleteCol1, nDeleteRow2+1, nTab), aPEnd); // 3
|
2012-08-31 03:59:51 +02:00
|
|
|
rNewRanges.push_back(aNewRange);
|
|
|
|
|
2012-09-21 15:12:40 -04:00
|
|
|
p->aEnd.SetCol(nDeleteCol1-1); // 1
|
2012-08-31 03:59:51 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
// +------+---+
|
|
|
|
// | 1 | |
|
|
|
|
// +---+------+ |
|
|
|
|
// |xxxxxxxxxx| 2 |
|
|
|
|
// +---+------+ |
|
|
|
|
// | 3 | |
|
|
|
|
// +------+---+
|
|
|
|
|
2012-09-21 20:20:18 -04:00
|
|
|
ScRange aNewRange(aPStart, ScAddress(nDeleteCol2, nDeleteRow1-1, nTab)); // 1
|
2012-08-31 03:59:51 +02:00
|
|
|
rNewRanges.push_back(aNewRange);
|
|
|
|
|
2012-09-21 20:20:18 -04:00
|
|
|
aNewRange = ScRange(nCol1, nDeleteRow2+1, nTab, nDeleteCol2, nRow2, nTab); // 3
|
2012-08-31 03:59:51 +02:00
|
|
|
rNewRanges.push_back(aNewRange);
|
|
|
|
|
2012-09-21 15:12:40 -04:00
|
|
|
p->aStart.SetCol(nDeleteCol2+1); // 2
|
2012-08-31 03:59:51 +02:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2012-09-21 15:12:40 -04:00
|
|
|
else if (checkForThreeRanges(nDeleteRow1, nDeleteRow2, nDeleteCol1, nDeleteCol2, nRow1, nRow2, nCol1, nCol2))
|
2012-08-31 03:59:51 +02:00
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
if (nRow1 < nDeleteRow1)
|
2012-08-31 03:59:51 +02:00
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
// +----------+
|
|
|
|
// | 1 |
|
|
|
|
// +---+--+---+
|
|
|
|
// | |xx| |
|
|
|
|
// | 2 |xx| 3 |
|
|
|
|
// | |xx| |
|
|
|
|
// +---+xx+---+
|
|
|
|
// |xx|
|
|
|
|
// +--+
|
|
|
|
|
|
|
|
ScRange aNewRange(nCol1, nDeleteRow1, nTab, nDeleteCol1-1, nRow2, nTab); // 2
|
2012-08-31 03:59:51 +02:00
|
|
|
rNewRanges.push_back( aNewRange );
|
|
|
|
|
2012-09-21 15:12:40 -04:00
|
|
|
aNewRange = ScRange(ScAddress(nDeleteCol2+1, nDeleteRow1, nTab), aPEnd); // 3
|
2012-08-31 03:59:51 +02:00
|
|
|
rNewRanges.push_back( aNewRange );
|
|
|
|
|
2012-09-21 15:12:40 -04:00
|
|
|
p->aEnd.SetRow(nDeleteRow1-1); // 1
|
2012-08-31 03:59:51 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
// +--+
|
|
|
|
// |xx|
|
|
|
|
// +---+xx+---+
|
|
|
|
// | 1 |xx| 2 |
|
|
|
|
// | |xx| |
|
|
|
|
// +---+--+---+
|
|
|
|
// | 3 |
|
|
|
|
// +----------+
|
|
|
|
|
|
|
|
ScRange aNewRange(aPStart, ScAddress(nDeleteCol1-1, nDeleteRow2, nTab)); // 1
|
2012-08-31 03:59:51 +02:00
|
|
|
rNewRanges.push_back(aNewRange);
|
|
|
|
|
2012-09-21 20:20:18 -04:00
|
|
|
aNewRange = ScRange(nDeleteCol2+1, nRow1, nTab, nCol2, nDeleteRow2, nTab); // 2
|
2012-08-31 03:59:51 +02:00
|
|
|
rNewRanges.push_back( aNewRange );
|
|
|
|
|
2012-09-21 15:12:40 -04:00
|
|
|
p->aStart.SetRow(nDeleteRow2+1); // 3
|
2012-08-31 03:59:51 +02:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool handleFourRanges( const ScRange& rDelRange, ScRange* p, std::vector<ScRange>& rNewRanges )
|
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
const ScAddress& rDelStart = rDelRange.aStart;
|
|
|
|
const ScAddress& rDelEnd = rDelRange.aEnd;
|
|
|
|
ScAddress aPStart = p->aStart;
|
|
|
|
ScAddress aPEnd = p->aEnd;
|
|
|
|
SCCOL nDeleteCol1 = rDelStart.Col();
|
|
|
|
SCCOL nDeleteCol2 = rDelEnd.Col();
|
|
|
|
SCROW nDeleteRow1 = rDelStart.Row();
|
|
|
|
SCROW nDeleteRow2 = rDelEnd.Row();
|
|
|
|
SCCOL nCol1 = aPStart.Col();
|
|
|
|
SCCOL nCol2 = aPEnd.Col();
|
|
|
|
SCROW nRow1 = aPStart.Row();
|
|
|
|
SCROW nRow2 = aPEnd.Row();
|
|
|
|
SCTAB nTab = aPStart.Tab();
|
|
|
|
|
|
|
|
if (nCol1 < nDeleteCol1 && nDeleteCol2 < nCol2 && nRow1 < nDeleteRow1 && nDeleteRow2 < nRow2)
|
2012-08-31 03:59:51 +02:00
|
|
|
{
|
2012-09-21 15:12:40 -04:00
|
|
|
// +---------------+
|
|
|
|
// | 1 |
|
|
|
|
// +---+-------+---+
|
|
|
|
// | |xxxxxxx| |
|
|
|
|
// | 2 |xxxxxxx| 3 |
|
|
|
|
// | |xxxxxxx| |
|
|
|
|
// +---+-------+---+
|
|
|
|
// | 4 |
|
|
|
|
// +---------------+
|
|
|
|
|
|
|
|
ScRange aNewRange(ScAddress(nCol1, nDeleteRow2+1, nTab), aPEnd); // 4
|
2012-08-31 03:59:51 +02:00
|
|
|
rNewRanges.push_back( aNewRange );
|
|
|
|
|
2012-09-21 15:12:40 -04:00
|
|
|
aNewRange = ScRange(nCol1, nDeleteRow1, nTab, nDeleteCol1-1, nDeleteRow2, nTab); // 2
|
2012-08-31 03:59:51 +02:00
|
|
|
rNewRanges.push_back( aNewRange );
|
|
|
|
|
2012-09-21 15:12:40 -04:00
|
|
|
aNewRange = ScRange(nDeleteCol2+1, nDeleteRow1, nTab, nCol2, nDeleteRow2, nTab); // 3
|
2012-08-31 03:59:51 +02:00
|
|
|
rNewRanges.push_back( aNewRange );
|
|
|
|
|
2012-09-21 15:12:40 -04:00
|
|
|
p->aEnd.SetRow(nDeleteRow1-1); // 1
|
2012-08-31 03:59:51 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScRangeList::DeleteArea( SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
|
|
|
|
SCCOL nCol2, SCROW nRow2, SCTAB nTab2 )
|
|
|
|
{
|
|
|
|
ScRange aRange( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
|
2012-09-17 14:41:19 +02:00
|
|
|
for(size_t i = 0; i < maRanges.size();)
|
|
|
|
{
|
2012-09-17 16:24:44 +02:00
|
|
|
if(FindRangeIn< ScRange >(aRange)(maRanges[i]))
|
2012-09-17 14:41:19 +02:00
|
|
|
{
|
|
|
|
ScRange* pRange = Remove(i);
|
|
|
|
delete pRange;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
++i;
|
|
|
|
}
|
2012-08-31 03:59:51 +02:00
|
|
|
|
|
|
|
std::vector<ScRange> aNewRanges;
|
|
|
|
|
|
|
|
for(iterator itr = maRanges.begin(); itr != maRanges.end(); ++itr)
|
|
|
|
{
|
|
|
|
// we have two basic cases here:
|
|
|
|
// 1. Delete area and pRange intersect
|
|
|
|
// 2. Delete area and pRange are not intersecting
|
|
|
|
// checking for 2 and if true skip this range
|
|
|
|
if(!(*itr)->Intersects(aRange))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// We get between 1 and 4 ranges from the difference of the first with the second
|
|
|
|
|
|
|
|
// X either Col or Row and Y then the opposite
|
|
|
|
// r = deleteRange, p = entry from ScRangeList
|
|
|
|
|
|
|
|
// getting exactly one range is the simple case
|
|
|
|
// r.aStart.X() <= p.aStart.X() && r.aEnd.X() >= p.aEnd.X()
|
|
|
|
// && ( r.aStart.Y() <= p.aStart.Y() || r.aEnd.Y() >= r.aEnd.Y() )
|
|
|
|
if(handleOneRange( aRange, *itr ))
|
2012-08-31 15:55:43 +02:00
|
|
|
continue;
|
2012-08-31 03:59:51 +02:00
|
|
|
|
|
|
|
// getting two ranges
|
|
|
|
// r.aStart.X()
|
|
|
|
else if(handleTwoRanges( aRange, *itr, aNewRanges ))
|
2012-08-31 15:55:43 +02:00
|
|
|
continue;
|
2012-08-31 03:59:51 +02:00
|
|
|
|
|
|
|
// getting 3 ranges
|
|
|
|
// r.aStart.X() > p.aStart.X() && r.aEnd.X() >= p.aEnd.X()
|
|
|
|
// && r.aStart.Y() > p.aStart.Y() && r.aEnd.Y() < p.aEnd.Y()
|
|
|
|
// or
|
|
|
|
// r.aStart.X() <= p.aStart.X() && r.aEnd.X() < p.aEnd.X()
|
|
|
|
// && r.aStart.Y() > p.aStart.Y() && r.aEnd.Y() < p.aEnd.Y()
|
|
|
|
else if(handleThreeRanges( aRange, *itr, aNewRanges ))
|
2012-08-31 15:55:43 +02:00
|
|
|
continue;
|
2012-08-31 03:59:51 +02:00
|
|
|
|
|
|
|
// getting 4 ranges
|
|
|
|
// r.aStart.X() > p.aStart.X() && r.aEnd().X() < p.aEnd.X()
|
|
|
|
// && r.aStart.Y() > p.aStart.Y() && r.aEnd().Y() < p.aEnd.Y()
|
|
|
|
else if(handleFourRanges( aRange, *itr, aNewRanges ))
|
2012-08-31 15:55:43 +02:00
|
|
|
continue;
|
2012-08-31 03:59:51 +02:00
|
|
|
}
|
|
|
|
for(vector<ScRange>::iterator itr = aNewRanges.begin(); itr != aNewRanges.end(); ++itr)
|
|
|
|
Join( *itr, false);
|
|
|
|
}
|
|
|
|
|
2010-12-09 20:25:50 -05:00
|
|
|
const ScRange* ScRangeList::Find( const ScAddress& rAdr ) const
|
|
|
|
{
|
2012-09-18 02:25:19 +02:00
|
|
|
const_iterator itr = find_if(
|
2010-12-10 12:21:14 -05:00
|
|
|
maRanges.begin(), maRanges.end(), FindEnclosingRange<ScAddress>(rAdr));
|
2010-12-09 20:25:50 -05:00
|
|
|
return itr == maRanges.end() ? NULL : *itr;
|
2010-12-09 20:07:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
ScRange* ScRangeList::Find( const ScAddress& rAdr )
|
|
|
|
{
|
2012-09-18 02:25:19 +02:00
|
|
|
iterator itr = find_if(
|
2010-12-10 12:21:14 -05:00
|
|
|
maRanges.begin(), maRanges.end(), FindEnclosingRange<ScAddress>(rAdr));
|
2010-12-09 20:25:50 -05:00
|
|
|
return itr == maRanges.end() ? NULL : *itr;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2011-09-09 17:24:55 -04:00
|
|
|
ScRangeList::ScRangeList() {}
|
|
|
|
|
2007-02-27 11:18:02 +00:00
|
|
|
ScRangeList::ScRangeList( const ScRangeList& rList ) :
|
|
|
|
SvRefBase()
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-12-10 12:06:57 -05:00
|
|
|
maRanges.reserve(rList.maRanges.size());
|
|
|
|
for_each(rList.maRanges.begin(), rList.maRanges.end(), AppendToList(maRanges));
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2011-09-09 17:24:55 -04:00
|
|
|
ScRangeList::ScRangeList( const ScRange& rRange )
|
|
|
|
{
|
|
|
|
maRanges.reserve(1);
|
|
|
|
Append(rRange);
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
ScRangeList& ScRangeList::operator=(const ScRangeList& rList)
|
|
|
|
{
|
2010-12-09 20:58:11 -05:00
|
|
|
RemoveAll();
|
2010-12-10 12:06:57 -05:00
|
|
|
maRanges.reserve(rList.maRanges.size());
|
|
|
|
for_each(rList.maRanges.begin(), rList.maRanges.end(), AppendToList(maRanges));
|
2000-09-18 23:16:46 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2011-09-09 17:24:55 -04:00
|
|
|
void ScRangeList::Append( const ScRange& rRange )
|
|
|
|
{
|
|
|
|
ScRange* pR = new ScRange( rRange );
|
|
|
|
maRanges.push_back( pR );
|
|
|
|
}
|
|
|
|
|
2010-12-08 22:38:24 -08:00
|
|
|
bool ScRangeList::Intersects( const ScRange& rRange ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-09-18 02:25:19 +02:00
|
|
|
const_iterator itrEnd = maRanges.end();
|
|
|
|
const_iterator itr =
|
2010-12-10 12:21:14 -05:00
|
|
|
find_if(maRanges.begin(), itrEnd, FindIntersectingRange<ScRange>(rRange));
|
|
|
|
return itr != itrEnd;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2010-12-08 22:38:24 -08:00
|
|
|
bool ScRangeList::In( const ScRange& rRange ) const
|
2001-04-24 13:44:36 +00:00
|
|
|
{
|
2012-09-18 02:25:19 +02:00
|
|
|
const_iterator itrEnd = maRanges.end();
|
|
|
|
const_iterator itr =
|
2010-12-10 12:21:14 -05:00
|
|
|
find_if(maRanges.begin(), itrEnd, FindEnclosingRange<ScRange>(rRange));
|
|
|
|
return itr != itrEnd;
|
2001-04-24 13:44:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 22:38:24 -08:00
|
|
|
size_t ScRangeList::GetCellCount() const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-12-10 12:31:10 -05:00
|
|
|
CountCells func;
|
|
|
|
return for_each(maRanges.begin(), maRanges.end(), func).getCellCount();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2010-12-09 20:07:11 -05:00
|
|
|
ScRange* ScRangeList::Remove(size_t nPos)
|
|
|
|
{
|
|
|
|
if (maRanges.size() <= nPos)
|
|
|
|
// Out-of-bound condition. Bail out.
|
|
|
|
return NULL;
|
|
|
|
|
2012-09-18 02:25:19 +02:00
|
|
|
iterator itr = maRanges.begin();
|
2010-12-09 20:07:11 -05:00
|
|
|
advance(itr, nPos);
|
|
|
|
ScRange* p = *itr;
|
|
|
|
maRanges.erase(itr);
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2010-12-09 20:58:11 -05:00
|
|
|
void ScRangeList::RemoveAll()
|
|
|
|
{
|
2011-06-07 17:09:21 -04:00
|
|
|
for_each(maRanges.begin(), maRanges.end(), ScDeleteObjectByPtr<ScRange>());
|
2010-12-09 20:58:11 -05:00
|
|
|
maRanges.clear();
|
|
|
|
}
|
|
|
|
|
2011-09-09 16:30:46 -04:00
|
|
|
ScRange ScRangeList::Combine() const
|
|
|
|
{
|
|
|
|
if (maRanges.empty())
|
|
|
|
return ScRange();
|
|
|
|
|
2012-09-18 02:25:19 +02:00
|
|
|
const_iterator itr = maRanges.begin(), itrEnd = maRanges.end();
|
2011-09-09 16:30:46 -04:00
|
|
|
ScRange aRet = **itr;
|
|
|
|
++itr;
|
|
|
|
for (; itr != itrEnd; ++itr)
|
|
|
|
{
|
|
|
|
const ScRange& r = **itr;
|
|
|
|
SCROW nRow1 = r.aStart.Row(), nRow2 = r.aEnd.Row();
|
2011-09-09 23:34:08 -04:00
|
|
|
SCCOL nCol1 = r.aStart.Col(), nCol2 = r.aEnd.Col();
|
|
|
|
SCTAB nTab1 = r.aStart.Tab(), nTab2 = r.aEnd.Tab();
|
2011-09-09 16:30:46 -04:00
|
|
|
if (aRet.aStart.Row() > nRow1)
|
|
|
|
aRet.aStart.SetRow(nRow1);
|
|
|
|
if (aRet.aStart.Col() > nCol1)
|
|
|
|
aRet.aStart.SetCol(nCol1);
|
2011-09-09 23:34:08 -04:00
|
|
|
if (aRet.aStart.Tab() > nTab1)
|
|
|
|
aRet.aStart.SetTab(nTab1);
|
2011-09-09 16:30:46 -04:00
|
|
|
if (aRet.aEnd.Row() < nRow2)
|
|
|
|
aRet.aEnd.SetRow(nRow2);
|
|
|
|
if (aRet.aEnd.Col() < nCol2)
|
|
|
|
aRet.aEnd.SetCol(nCol2);
|
2011-09-09 23:34:08 -04:00
|
|
|
if (aRet.aEnd.Tab() < nTab2)
|
|
|
|
aRet.aEnd.SetTab(nTab2);
|
2011-09-09 16:30:46 -04:00
|
|
|
}
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
2010-12-09 20:07:11 -05:00
|
|
|
bool ScRangeList::empty() const
|
|
|
|
{
|
|
|
|
return maRanges.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t ScRangeList::size() const
|
|
|
|
{
|
|
|
|
return maRanges.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
ScRange* ScRangeList::operator [](size_t idx)
|
|
|
|
{
|
|
|
|
return maRanges[idx];
|
|
|
|
}
|
|
|
|
|
|
|
|
const ScRange* ScRangeList::operator [](size_t idx) const
|
|
|
|
{
|
|
|
|
return maRanges[idx];
|
|
|
|
}
|
|
|
|
|
|
|
|
ScRange* ScRangeList::front()
|
|
|
|
{
|
|
|
|
return maRanges.front();
|
|
|
|
}
|
|
|
|
|
|
|
|
const ScRange* ScRangeList::front() const
|
|
|
|
{
|
|
|
|
return maRanges.front();
|
|
|
|
}
|
|
|
|
|
|
|
|
ScRange* ScRangeList::back()
|
|
|
|
{
|
|
|
|
return maRanges.back();
|
|
|
|
}
|
|
|
|
|
|
|
|
const ScRange* ScRangeList::back() const
|
|
|
|
{
|
|
|
|
return maRanges.back();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScRangeList::push_back(ScRange* p)
|
|
|
|
{
|
|
|
|
maRanges.push_back(p);
|
|
|
|
}
|
|
|
|
|
2012-09-28 13:40:47 +01:00
|
|
|
ScAddress ScRangeList::GetTopLeftCorner() const
|
|
|
|
{
|
|
|
|
if(empty())
|
|
|
|
return ScAddress();
|
|
|
|
|
|
|
|
ScAddress aAddr = maRanges[0]->aStart;
|
|
|
|
for(size_t i = 1, n = size(); i < n; ++i)
|
|
|
|
{
|
|
|
|
if(maRanges[i]->aStart < aAddr)
|
|
|
|
aAddr = maRanges[i]->aStart;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aAddr;
|
|
|
|
}
|
|
|
|
|
2012-12-25 21:04:15 +01:00
|
|
|
ScRangeList ScRangeList::GetIntersectedRange(const ScRange& rRange) const
|
|
|
|
{
|
|
|
|
ScRangeList aReturn;
|
|
|
|
for(const_iterator itr = maRanges.begin(), itrEnd = maRanges.end();
|
|
|
|
itr != itrEnd; ++itr)
|
|
|
|
{
|
|
|
|
if((*itr)->Intersects(rRange))
|
|
|
|
{
|
|
|
|
SCCOL nColStart1, nColEnd1, nColStart2, nColEnd2;
|
|
|
|
SCROW nRowStart1, nRowEnd1, nRowStart2, nRowEnd2;
|
|
|
|
SCTAB nTabStart1, nTabEnd1, nTabStart2, nTabEnd2;
|
|
|
|
(*itr)->GetVars(nColStart1, nRowStart1, nTabStart1,
|
|
|
|
nColEnd1, nRowEnd1, nTabEnd1);
|
|
|
|
rRange.GetVars(nColStart2, nRowStart2, nTabStart2,
|
|
|
|
nColEnd2, nRowEnd2, nTabEnd2);
|
|
|
|
|
|
|
|
ScRange aNewRange(std::max<SCCOL>(nColStart1, nColStart2), std::max<SCROW>(nRowStart1, nRowStart2),
|
|
|
|
std::max<SCTAB>(nTabStart1, nTabStart2), std::min<SCCOL>(nColEnd1, nColEnd2),
|
|
|
|
std::min<SCROW>(nRowEnd1, nRowEnd2), std::min<SCTAB>(nTabEnd1, nTabEnd2));
|
|
|
|
aReturn.Join(aNewRange);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return aReturn;
|
|
|
|
}
|
|
|
|
|
2010-12-09 22:21:29 -08:00
|
|
|
// === ScRangePairList ========================================================
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
ScRangePairList::~ScRangePairList()
|
|
|
|
{
|
2011-06-07 17:09:21 -04:00
|
|
|
for_each( maPairs.begin(), maPairs.end(), ScDeleteObjectByPtr<ScRangePair>() );
|
2010-12-09 22:21:29 -08:00
|
|
|
maPairs.clear();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2010-12-09 22:21:29 -08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
ScRangePair* ScRangePairList::Remove(size_t nPos)
|
|
|
|
{
|
|
|
|
if (maPairs.size() <= nPos)
|
|
|
|
// Out-of-bound condition. Bail out.
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
vector<ScRangePair*>::iterator itr = maPairs.begin();
|
|
|
|
advance(itr, nPos);
|
|
|
|
ScRangePair* p = *itr;
|
|
|
|
maPairs.erase(itr);
|
|
|
|
return p;
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2010-12-09 22:21:29 -08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
ScRangePair* ScRangePairList::Remove( ScRangePair* Adr)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-12-09 22:21:29 -08:00
|
|
|
ScRangePair* p = NULL;
|
|
|
|
|
|
|
|
if (Adr == NULL) return NULL;
|
|
|
|
|
|
|
|
for ( vector<ScRangePair*>::iterator itr = maPairs.begin(); itr < maPairs.end(); ++itr )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-12-09 22:21:29 -08:00
|
|
|
if ( Adr == (p = *itr) )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-12-09 22:21:29 -08:00
|
|
|
maPairs.erase( itr );
|
|
|
|
break;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
2010-12-09 22:21:29 -08:00
|
|
|
return p;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2010-12-09 22:21:29 -08:00
|
|
|
bool ScRangePairList::operator==( const ScRangePairList& r ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if ( this == &r )
|
2010-12-09 22:21:29 -08:00
|
|
|
return true; // identische Referenz
|
|
|
|
if ( maPairs.size() != r.size() )
|
|
|
|
return false;
|
|
|
|
for ( size_t nIdx = 0, nCnt = maPairs.size(); nIdx < nCnt; ++nIdx )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-12-09 22:21:29 -08:00
|
|
|
if ( *maPairs[ nIdx ] != *r[ nIdx ] )
|
|
|
|
return false; // auch andere Reihenfolge ist ungleich
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-12-09 22:21:29 -08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-12-10 16:31:56 -05:00
|
|
|
ScRangePair* ScRangePairList::operator [](size_t idx)
|
2010-12-09 22:21:29 -08:00
|
|
|
{
|
|
|
|
return maPairs[idx];
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2010-12-10 16:31:56 -05:00
|
|
|
const ScRangePair* ScRangePairList::operator [](size_t idx) const
|
2010-12-09 22:21:29 -08:00
|
|
|
{
|
2010-12-10 16:31:56 -05:00
|
|
|
return maPairs[idx];
|
2010-12-09 22:21:29 -08:00
|
|
|
}
|
|
|
|
|
2010-12-10 16:31:56 -05:00
|
|
|
size_t ScRangePairList::size() const
|
2010-12-09 22:21:29 -08:00
|
|
|
{
|
2010-12-10 16:31:56 -05:00
|
|
|
return maPairs.size();
|
2010-12-09 22:21:29 -08:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2010-12-09 22:21:29 -08:00
|
|
|
bool ScRangePairList::UpdateReference( UpdateRefMode eUpdateRefMode,
|
2000-09-18 23:16:46 +00:00
|
|
|
ScDocument* pDoc, const ScRange& rWhere,
|
2004-06-04 09:38:10 +00:00
|
|
|
SCsCOL nDx, SCsROW nDy, SCsTAB nDz )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-12-09 22:21:29 -08:00
|
|
|
bool bChanged = false;
|
|
|
|
if ( !maPairs.empty() )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:38:10 +00:00
|
|
|
SCCOL nCol1;
|
|
|
|
SCROW nRow1;
|
|
|
|
SCTAB nTab1;
|
|
|
|
SCCOL nCol2;
|
|
|
|
SCROW nRow2;
|
|
|
|
SCTAB nTab2;
|
2000-09-18 23:16:46 +00:00
|
|
|
rWhere.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
|
2010-12-09 22:21:29 -08:00
|
|
|
for ( size_t i = 0, nPairs = maPairs.size(); i < nPairs; ++i )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-12-09 22:21:29 -08:00
|
|
|
ScRangePair* pR = maPairs[ i ];
|
2011-01-17 13:20:22 +01:00
|
|
|
for ( sal_uInt16 j=0; j<2; j++ )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
ScRange& rRange = pR->GetRange(j);
|
2004-06-04 09:38:10 +00:00
|
|
|
SCCOL theCol1;
|
|
|
|
SCROW theRow1;
|
|
|
|
SCTAB theTab1;
|
|
|
|
SCCOL theCol2;
|
|
|
|
SCROW theRow2;
|
|
|
|
SCTAB theTab2;
|
2000-09-18 23:16:46 +00:00
|
|
|
rRange.GetVars( theCol1, theRow1, theTab1, theCol2, theRow2, theTab2 );
|
|
|
|
if ( ScRefUpdate::Update( pDoc, eUpdateRefMode,
|
|
|
|
nCol1, nRow1, nTab1, nCol2, nRow2, nTab2,
|
|
|
|
nDx, nDy, nDz,
|
|
|
|
theCol1, theRow1, theTab1, theCol2, theRow2, theTab2 )
|
|
|
|
!= UR_NOTHING )
|
|
|
|
{
|
2010-12-09 22:21:29 -08:00
|
|
|
bChanged = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
rRange.aStart.Set( theCol1, theRow1, theTab1 );
|
|
|
|
rRange.aEnd.Set( theCol2, theRow2, theTab2 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return bChanged;
|
|
|
|
}
|
|
|
|
|
2010-12-09 22:21:29 -08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Delete entries that have the labels (first range) on nTab
|
2005-09-28 10:39:04 +00:00
|
|
|
void ScRangePairList::DeleteOnTab( SCTAB nTab )
|
|
|
|
{
|
2010-12-09 22:21:29 -08:00
|
|
|
size_t nListCount = maPairs.size();
|
|
|
|
size_t nPos = 0;
|
2007-02-27 11:18:02 +00:00
|
|
|
while ( nPos < nListCount )
|
2005-09-28 10:39:04 +00:00
|
|
|
{
|
2010-12-09 22:21:29 -08:00
|
|
|
ScRangePair* pR = maPairs[ nPos ];
|
2005-09-28 10:39:04 +00:00
|
|
|
ScRange aRange = pR->GetRange(0);
|
|
|
|
if ( aRange.aStart.Tab() == nTab && aRange.aEnd.Tab() == nTab )
|
|
|
|
{
|
|
|
|
Remove( nPos );
|
|
|
|
delete pR;
|
2010-12-09 22:21:29 -08:00
|
|
|
nListCount = maPairs.size();
|
2005-09-28 10:39:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
++nPos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-09 22:21:29 -08:00
|
|
|
//-----------------------------------------------------------------------------
|
2000-09-18 23:16:46 +00:00
|
|
|
ScRangePair* ScRangePairList::Find( const ScAddress& rAdr ) const
|
|
|
|
{
|
2010-12-09 22:21:29 -08:00
|
|
|
for ( size_t j = 0, nListCount = maPairs.size(); j < nListCount; j++ )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-12-09 22:21:29 -08:00
|
|
|
ScRangePair* pR = maPairs[ j ];
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( pR->GetRange(0).In( rAdr ) )
|
|
|
|
return pR;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-12-09 22:21:29 -08:00
|
|
|
//-----------------------------------------------------------------------------
|
2000-09-18 23:16:46 +00:00
|
|
|
ScRangePair* ScRangePairList::Find( const ScRange& rRange ) const
|
|
|
|
{
|
2010-12-09 22:21:29 -08:00
|
|
|
for ( size_t j = 0, nListCount = maPairs.size(); j < nListCount; j++ )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-12-09 22:21:29 -08:00
|
|
|
ScRangePair* pR = maPairs[ j ];
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( pR->GetRange(0) == rRange )
|
|
|
|
return pR;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-09 22:21:29 -08:00
|
|
|
//-----------------------------------------------------------------------------
|
2000-09-18 23:16:46 +00:00
|
|
|
ScRangePairList* ScRangePairList::Clone() const
|
|
|
|
{
|
|
|
|
ScRangePairList* pNew = new ScRangePairList;
|
2010-12-09 22:21:29 -08:00
|
|
|
for ( size_t j = 0, nListCount = maPairs.size(); j < nListCount; j++ )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-12-09 22:21:29 -08:00
|
|
|
pNew->Append( *maPairs[ j ] );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
return pNew;
|
|
|
|
}
|
|
|
|
|
2010-12-09 22:21:29 -08:00
|
|
|
//-----------------------------------------------------------------------------
|
2000-09-18 23:16:46 +00:00
|
|
|
struct ScRangePairNameSort
|
|
|
|
{
|
|
|
|
ScRangePair* pPair;
|
|
|
|
ScDocument* pDoc;
|
|
|
|
};
|
|
|
|
|
2010-12-09 22:21:29 -08:00
|
|
|
//-----------------------------------------------------------------------------
|
2011-05-26 16:34:43 +02:00
|
|
|
extern "C"
|
|
|
|
int SAL_CALL ScRangePairList_QsortNameCompare( const void* p1, const void* p2 )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
const ScRangePairNameSort* ps1 = (const ScRangePairNameSort*)p1;
|
|
|
|
const ScRangePairNameSort* ps2 = (const ScRangePairNameSort*)p2;
|
2007-02-27 11:18:02 +00:00
|
|
|
const ScAddress& rStartPos1 = ps1->pPair->GetRange(0).aStart;
|
|
|
|
const ScAddress& rStartPos2 = ps2->pPair->GetRange(0).aStart;
|
2011-08-26 19:33:59 -04:00
|
|
|
rtl::OUString aStr1, aStr2;
|
2001-03-14 15:02:54 +00:00
|
|
|
sal_Int32 nComp;
|
2007-02-27 11:18:02 +00:00
|
|
|
if ( rStartPos1.Tab() == rStartPos2.Tab() )
|
2001-03-14 15:02:54 +00:00
|
|
|
nComp = COMPARE_EQUAL;
|
2000-09-18 23:16:46 +00:00
|
|
|
else
|
|
|
|
{
|
2007-02-27 11:18:02 +00:00
|
|
|
ps1->pDoc->GetName( rStartPos1.Tab(), aStr1 );
|
|
|
|
ps2->pDoc->GetName( rStartPos2.Tab(), aStr2 );
|
2009-09-08 04:57:32 +00:00
|
|
|
nComp = ScGlobal::GetCollator()->compareString( aStr1, aStr2 );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2001-03-14 15:02:54 +00:00
|
|
|
switch ( nComp )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
case COMPARE_LESS:
|
|
|
|
return -1;
|
2007-02-27 11:18:02 +00:00
|
|
|
//break;
|
2000-09-18 23:16:46 +00:00
|
|
|
case COMPARE_GREATER:
|
|
|
|
return 1;
|
2007-02-27 11:18:02 +00:00
|
|
|
//break;
|
2000-09-18 23:16:46 +00:00
|
|
|
default:
|
|
|
|
// gleiche Tabs
|
2007-02-27 11:18:02 +00:00
|
|
|
if ( rStartPos1.Col() < rStartPos2.Col() )
|
2000-09-18 23:16:46 +00:00
|
|
|
return -1;
|
2007-02-27 11:18:02 +00:00
|
|
|
if ( rStartPos1.Col() > rStartPos2.Col() )
|
2000-09-18 23:16:46 +00:00
|
|
|
return 1;
|
|
|
|
// gleiche Cols
|
2007-02-27 11:18:02 +00:00
|
|
|
if ( rStartPos1.Row() < rStartPos2.Row() )
|
2000-09-18 23:16:46 +00:00
|
|
|
return -1;
|
2007-02-27 11:18:02 +00:00
|
|
|
if ( rStartPos1.Row() > rStartPos2.Row() )
|
2000-09-18 23:16:46 +00:00
|
|
|
return 1;
|
|
|
|
// erste Ecke gleich, zweite Ecke
|
|
|
|
{
|
2007-02-27 11:18:02 +00:00
|
|
|
const ScAddress& rEndPos1 = ps1->pPair->GetRange(0).aEnd;
|
|
|
|
const ScAddress& rEndPos2 = ps2->pPair->GetRange(0).aEnd;
|
|
|
|
if ( rEndPos1.Tab() == rEndPos2.Tab() )
|
2001-03-14 15:02:54 +00:00
|
|
|
nComp = COMPARE_EQUAL;
|
2000-09-18 23:16:46 +00:00
|
|
|
else
|
|
|
|
{
|
2007-02-27 11:18:02 +00:00
|
|
|
ps1->pDoc->GetName( rEndPos1.Tab(), aStr1 );
|
|
|
|
ps2->pDoc->GetName( rEndPos2.Tab(), aStr2 );
|
2009-09-08 04:57:32 +00:00
|
|
|
nComp = ScGlobal::GetCollator()->compareString( aStr1, aStr2 );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2001-03-14 15:02:54 +00:00
|
|
|
switch ( nComp )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
case COMPARE_LESS:
|
|
|
|
return -1;
|
2007-02-27 11:18:02 +00:00
|
|
|
//break;
|
2000-09-18 23:16:46 +00:00
|
|
|
case COMPARE_GREATER:
|
|
|
|
return 1;
|
2007-02-27 11:18:02 +00:00
|
|
|
//break;
|
2000-09-18 23:16:46 +00:00
|
|
|
default:
|
|
|
|
// gleiche Tabs
|
2007-02-27 11:18:02 +00:00
|
|
|
if ( rEndPos1.Col() < rEndPos2.Col() )
|
2000-09-18 23:16:46 +00:00
|
|
|
return -1;
|
2007-02-27 11:18:02 +00:00
|
|
|
if ( rEndPos1.Col() > rEndPos2.Col() )
|
2000-09-18 23:16:46 +00:00
|
|
|
return 1;
|
|
|
|
// gleiche Cols
|
2007-02-27 11:18:02 +00:00
|
|
|
if ( rEndPos1.Row() < rEndPos2.Row() )
|
2000-09-18 23:16:46 +00:00
|
|
|
return -1;
|
2007-02-27 11:18:02 +00:00
|
|
|
if ( rEndPos1.Row() > rEndPos2.Row() )
|
2000-09-18 23:16:46 +00:00
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-10-17 18:58:12 +03:00
|
|
|
#ifndef _MSC_VER // MSVC is good enough to warn about unreachable code here.
|
|
|
|
// Or stupid enough to bother warning about it, depending
|
|
|
|
// on your point of view.
|
2006-10-18 11:23:03 +00:00
|
|
|
return 0; // just in case
|
2011-10-17 18:58:12 +03:00
|
|
|
#endif
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2010-12-09 22:21:29 -08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void ScRangePairList::Join( const ScRangePair& r, bool bIsInList )
|
|
|
|
{
|
|
|
|
if ( maPairs.empty() )
|
|
|
|
{
|
|
|
|
Append( r );
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
const ScRange& r1 = r.GetRange(0);
|
|
|
|
const ScRange& r2 = r.GetRange(1);
|
|
|
|
SCCOL nCol1 = r1.aStart.Col();
|
|
|
|
SCROW nRow1 = r1.aStart.Row();
|
|
|
|
SCTAB nTab1 = r1.aStart.Tab();
|
|
|
|
SCCOL nCol2 = r1.aEnd.Col();
|
|
|
|
SCROW nRow2 = r1.aEnd.Row();
|
|
|
|
SCTAB nTab2 = r1.aEnd.Tab();
|
|
|
|
ScRangePair* pOver = (ScRangePair*) &r; // fies aber wahr wenn bInList
|
|
|
|
size_t nOldPos = 0;
|
|
|
|
if ( bIsInList )
|
|
|
|
{
|
|
|
|
// Find the current position of this range.
|
|
|
|
for ( size_t i = 0, nPairs = maPairs.size(); i < nPairs; ++i )
|
|
|
|
{
|
|
|
|
if ( maPairs[i] == pOver )
|
|
|
|
{
|
|
|
|
nOldPos = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool bJoinedInput = false;
|
|
|
|
|
2011-05-25 01:21:30 +02:00
|
|
|
for ( size_t i = 0; i < maPairs.size() && pOver; ++i )
|
2010-12-09 22:21:29 -08:00
|
|
|
{
|
|
|
|
ScRangePair* p = maPairs[ i ];
|
|
|
|
if ( p == pOver )
|
|
|
|
continue; // derselbe, weiter mit dem naechsten
|
|
|
|
bool bJoined = false;
|
|
|
|
ScRange& rp1 = p->GetRange(0);
|
|
|
|
ScRange& rp2 = p->GetRange(1);
|
|
|
|
if ( rp2 == r2 )
|
|
|
|
{ // nur wenn Range2 gleich ist
|
|
|
|
if ( rp1.In( r1 ) )
|
|
|
|
{ // RangePair r in RangePair p enthalten oder identisch
|
|
|
|
if ( bIsInList )
|
|
|
|
bJoined = true; // weg mit RangePair r
|
|
|
|
else
|
|
|
|
{ // das war's dann
|
|
|
|
bJoinedInput = true; // nicht anhaengen
|
|
|
|
break; // for
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( r1.In( rp1 ) )
|
|
|
|
{ // RangePair p in RangePair r enthalten, r zum neuen RangePair machen
|
|
|
|
*p = r;
|
|
|
|
bJoined = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( !bJoined && rp1.aStart.Tab() == nTab1 && rp1.aEnd.Tab() == nTab2
|
|
|
|
&& rp2.aStart.Tab() == r2.aStart.Tab()
|
|
|
|
&& rp2.aEnd.Tab() == r2.aEnd.Tab() )
|
|
|
|
{ // 2D, Range2 muss genauso nebeneinander liegen wie Range1
|
|
|
|
if ( rp1.aStart.Col() == nCol1 && rp1.aEnd.Col() == nCol2
|
|
|
|
&& rp2.aStart.Col() == r2.aStart.Col()
|
|
|
|
&& rp2.aEnd.Col() == r2.aEnd.Col() )
|
|
|
|
{
|
|
|
|
if ( rp1.aStart.Row() == nRow2+1
|
|
|
|
&& rp2.aStart.Row() == r2.aEnd.Row()+1 )
|
|
|
|
{ // oben
|
|
|
|
rp1.aStart.SetRow( nRow1 );
|
|
|
|
rp2.aStart.SetRow( r2.aStart.Row() );
|
|
|
|
bJoined = true;
|
|
|
|
}
|
|
|
|
else if ( rp1.aEnd.Row() == nRow1-1
|
|
|
|
&& rp2.aEnd.Row() == r2.aStart.Row()-1 )
|
|
|
|
{ // unten
|
|
|
|
rp1.aEnd.SetRow( nRow2 );
|
|
|
|
rp2.aEnd.SetRow( r2.aEnd.Row() );
|
|
|
|
bJoined = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( rp1.aStart.Row() == nRow1 && rp1.aEnd.Row() == nRow2
|
|
|
|
&& rp2.aStart.Row() == r2.aStart.Row()
|
|
|
|
&& rp2.aEnd.Row() == r2.aEnd.Row() )
|
|
|
|
{
|
|
|
|
if ( rp1.aStart.Col() == nCol2+1
|
|
|
|
&& rp2.aStart.Col() == r2.aEnd.Col()+1 )
|
|
|
|
{ // links
|
|
|
|
rp1.aStart.SetCol( nCol1 );
|
|
|
|
rp2.aStart.SetCol( r2.aStart.Col() );
|
|
|
|
bJoined = true;
|
|
|
|
}
|
|
|
|
else if ( rp1.aEnd.Col() == nCol1-1
|
|
|
|
&& rp2.aEnd.Col() == r2.aEnd.Col()-1 )
|
|
|
|
{ // rechts
|
|
|
|
rp1.aEnd.SetCol( nCol2 );
|
|
|
|
rp2.aEnd.SetCol( r2.aEnd.Col() );
|
|
|
|
bJoined = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( bJoined )
|
|
|
|
{
|
|
|
|
if ( bIsInList )
|
|
|
|
{ // innerhalb der Liste RangePair loeschen
|
|
|
|
Remove( nOldPos );
|
2011-05-25 01:21:30 +02:00
|
|
|
i--;
|
2010-12-09 22:21:29 -08:00
|
|
|
delete pOver;
|
|
|
|
pOver = NULL;
|
|
|
|
if ( nOldPos )
|
|
|
|
nOldPos--; // Seek richtig aufsetzen
|
|
|
|
}
|
|
|
|
bJoinedInput = true;
|
|
|
|
Join( *p, true ); // rekursiv!
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( !bIsInList && !bJoinedInput )
|
|
|
|
Append( r );
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2010-12-09 22:21:29 -08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
ScRangePair** ScRangePairList::CreateNameSortedArray( size_t& nListCount,
|
2000-09-18 23:16:46 +00:00
|
|
|
ScDocument* pDoc ) const
|
|
|
|
{
|
2010-12-09 22:21:29 -08:00
|
|
|
nListCount = maPairs.size();
|
2011-05-21 13:29:51 +02:00
|
|
|
OSL_ENSURE( nListCount * sizeof(ScRangePairNameSort) <= (size_t)~0x1F,
|
2007-02-27 11:18:02 +00:00
|
|
|
"ScRangePairList::CreateNameSortedArray nListCount * sizeof(ScRangePairNameSort) > (size_t)~0x1F" );
|
2000-09-18 23:16:46 +00:00
|
|
|
ScRangePairNameSort* pSortArray = (ScRangePairNameSort*)
|
2011-01-17 13:20:22 +01:00
|
|
|
new sal_uInt8 [ nListCount * sizeof(ScRangePairNameSort) ];
|
|
|
|
sal_uLong j;
|
2007-02-27 11:18:02 +00:00
|
|
|
for ( j=0; j < nListCount; j++ )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-12-09 22:21:29 -08:00
|
|
|
pSortArray[j].pPair = maPairs[ j ];
|
2000-09-18 23:16:46 +00:00
|
|
|
pSortArray[j].pDoc = pDoc;
|
|
|
|
}
|
2007-02-27 11:18:02 +00:00
|
|
|
qsort( (void*)pSortArray, nListCount, sizeof(ScRangePairNameSort), &ScRangePairList_QsortNameCompare );
|
2000-09-18 23:16:46 +00:00
|
|
|
// ScRangePair Pointer aufruecken
|
|
|
|
ScRangePair** ppSortArray = (ScRangePair**)pSortArray;
|
2007-02-27 11:18:02 +00:00
|
|
|
for ( j=0; j < nListCount; j++ )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
ppSortArray[j] = pSortArray[j].pPair;
|
|
|
|
}
|
|
|
|
return ppSortArray;
|
|
|
|
}
|
|
|
|
|
2010-10-12 15:59:00 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|