24#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
25#include <com/sun/star/sheet/NamedRangeFlag.hpp>
26#include <com/sun/star/awt/XBitmap.hpp>
27#include <com/sun/star/beans/PropertyAttribute.hpp>
34using ::com::sun::star::uno::Reference;
35using ::com::sun::star::uno::Any;
43#include <tokenarray.hxx>
47#include <unonames.hxx>
60 return aNamedRangeMap_Impl;
69 return aNamedRangesMap_Impl;
106 if ( rHint.
GetId() == SfxHintId::Dying )
143 assert(bFound); (void)bFound;
173 std::unique_ptr<ScRangeName> pNewRanges(
new ScRangeName(*pNames));
175 OUString aInsName = pOld->
GetName();
177 aInsName = *pNewName;
180 OUString aContent = pOld->
GetSymbol(eGrammar);
182 aContent = *pNewContent;
200 pNewRanges->erase(*pOld);
201 if (pNewRanges->insert(pNew))
224 OUString aNewStr(aNewName);
228 if (
aName != aNewStr )
229 throw uno::RuntimeException();
246 OUString aContStr(aContent);
257 aPos =
pData->GetPos();
258 table::CellAddress aAddress;
259 aAddress.Column = aPos.
Col();
260 aAddress.Row = aPos.
Row();
261 aAddress.Sheet = aPos.
Tab();
265 if ( aAddress.Sheet >= nDocTabs && nDocTabs > 0 )
270 aAddress.Sheet = nDocTabs - 1;
279 ScAddress aPos(
static_cast<SCCOL>(aReferencePosition.Column),
static_cast<SCROW>(aReferencePosition.Row), aReferencePosition.Sheet );
318 uno::Sequence<sheet::FormulaToken> aSequence;
348 if (
pData &&
pData->IsValidReference( aRange ) )
369 const OUString& rPropertyName,
const uno::Any& )
393 aRet <<= static_cast<sal_Int32>(
pData->GetIndex());
409 return "ScNamedRangeObj";
423 mbModifyAndBroadcast(true),
441 if ( rHint.
GetId() == SfxHintId::Dying )
450 const OUString& aContent,
const table::CellAddress& aPosition,
454 ScAddress aPos(
static_cast<SCCOL>(aPosition.Column),
static_cast<SCROW>(aPosition.Row), aPosition.Sheet );
470 throw uno::RuntimeException(
471 "Invalid name. Reference to a cell, or a range of cells not allowed",
475 throw uno::RuntimeException(
476 "Invalid name. Start with a letter, use only letters, numbers and underscore",
484 std::unique_ptr<ScRangeName> pNewRanges(
new ScRangeName( *pNames ));
488 if ( pNewRanges->insert(pNew) )
502 throw uno::RuntimeException();
506 sheet::Border aBorder )
511 bool bTop = ( aBorder == sheet::Border_TOP );
512 bool bLeft = ( aBorder == sheet::Border_LEFT );
513 bool bBottom = ( aBorder == sheet::Border_BOTTOM );
514 bool bRight = ( aBorder == sheet::Border_RIGHT );
541 std::unique_ptr<ScRangeName> pNewRanges(
new ScRangeName(*pNames));
542 pNewRanges->erase(*
pData);
550 throw uno::RuntimeException();
556 ScAddress aPos(
static_cast<SCCOL>(aOutputPosition.Column),
static_cast<SCROW>(aOutputPosition.Row), aOutputPosition.Sheet );
580 for (
const auto& rName : *pNames)
593 throw lang::IndexOutOfBoundsException();
611 static Reference<beans::XPropertySetInfo> aRef(
617 const OUString& rPropertyName,
const uno::Any& aValue )
641 uno::Reference< sheet::XNamedRange > xRange(GetObjectByName_Impl(
aName));
643 throw container::NoSuchElementException();
657 uno::Sequence<OUString>
aSeq(nVisCount);
658 OUString* pAry =
aSeq.getArray();
659 sal_uInt16 nVisPos = 0;
660 for (
const auto& rName : *pNames)
663 pAry[nVisPos++] = rName.second->GetName();
713 if ( nLockCount == 1 )
725 if ( nLockCount > 0 )
728 if ( nLockCount == 0 )
744 if ( nLock == 0 && nLockCount > 0 )
748 if ( nLock > 0 && nLockCount == 0 )
760 if ( nLockCount > 0 )
789 for (
const auto& rName : *pNames)
820 mxSheet(
std::move(xSheet))
854 for (
const auto& rName : *pNames)
899 if ( rHint.
GetId() == SfxHintId::Dying )
938 xNewList->Join( *pEntry,
true );
960 table::CellRangeAddress aRet;
978 table::CellRangeAddress aRet;
1012 if ( rHint.
GetId() == SfxHintId::Dying )
1026 if ( pList && nIndex < pList->
size() )
1036 const table::CellRangeAddress& aDataArea )
1053 xNewList->Join(
ScRangePair( aLabelRange, aDataRange ) );
1080 xNewList->Remove(
nIndex );
1096 throw uno::RuntimeException();
1117 return pList->
size();
1127 throw lang::IndexOutOfBoundsException();
unotools::WeakReference< AnimationNode > mxParent
really derive cell from range?
bool CreateNames(const ScRange &rRange, CreateNameFlags nFlags, bool bApi, SCTAB nTab=-1)
void SetNewRangeNames(std::unique_ptr< ScRangeName > pNewRanges, bool bModifyDoc, SCTAB nTab)
bool InsertNameList(const ScAddress &rStartPos, bool bApi)
void SetDocumentModified()
const ScDocument & GetDocument() const
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
SC_DLLPUBLIC bool GetTable(const OUString &rName, SCTAB &rTab) const
SC_DLLPUBLIC void CompileHybridFormula()
Call this immediately after updating named ranges.
ScRangePairList * GetRowNameRanges()
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC SCROW MaxRow() const
SC_DLLPUBLIC sal_Int16 GetNamedRangesLockCount() const
SC_DLLPUBLIC void PreprocessRangeNameUpdate()
ScRangePairListRef & GetRowNameRangesRef()
void AddUnoObject(SfxListener &rObject)
ScRangePairList * GetColNameRanges()
ScRangePairListRef & GetColNameRangesRef()
void SetNamedRangesLockCount(sal_Int16 nCount)
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
void RemoveUnoObject(SfxListener &rObject)
void CompileColRowNameFormula()
SC_DLLPUBLIC SCTAB GetTableCount() const
virtual ~ScGlobalNamedRangesObj() override
virtual ScRangeName * GetRangeName_Impl() override
virtual rtl::Reference< ScNamedRangeObj > GetObjectByName_Impl(const OUString &aName) override
ScGlobalNamedRangesObj(ScDocShell *pDocSh)
virtual SCTAB GetTab_Impl() override
virtual rtl::Reference< ScNamedRangeObj > GetObjectByIndex_Impl(sal_uInt16 nIndex) override
static SC_DLLPUBLIC const CharClass & getCharClass()
ScRange aRange
criterion to find range
virtual void SAL_CALL setDataArea(const css::table::CellRangeAddress &aDataArea) override
virtual css::table::CellRangeAddress SAL_CALL getLabelArea() override
XLabelRange.
virtual ~ScLabelRangeObj() override
virtual css::table::CellRangeAddress SAL_CALL getDataArea() override
ScLabelRangeObj(ScDocShell *pDocSh, bool bCol, const ScRange &rR)
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
virtual void SAL_CALL setLabelArea(const css::table::CellRangeAddress &aLabelArea) override
void Modify_Impl(const ScRange *pLabel, const ScRange *pData)
ScRangePair * GetData_Impl()
rtl::Reference< ScLabelRangeObj > GetObjectByIndex_Impl(size_t nIndex)
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
virtual sal_Int32 SAL_CALL getCount() override
XIndexAccess.
ScLabelRangesObj(ScDocShell *pDocSh, bool bCol)
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
XEnumerationAccess.
virtual sal_Bool SAL_CALL hasElements() override
virtual void SAL_CALL removeByIndex(sal_Int32 nIndex) override
virtual css::uno::Type SAL_CALL getElementType() override
XElementAccess.
virtual void SAL_CALL addNew(const css::table::CellRangeAddress &aLabelArea, const css::table::CellRangeAddress &aDataArea) override
XLabelRanges.
virtual ~ScLabelRangesObj() override
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
virtual ~ScLocalNamedRangesObj() override
virtual rtl::Reference< ScNamedRangeObj > GetObjectByIndex_Impl(sal_uInt16 nIndex) override
virtual SCTAB GetTab_Impl() override
virtual ScRangeName * GetRangeName_Impl() override
css::uno::Reference< css::container::XNamed > mxSheet
ScLocalNamedRangesObj(ScDocShell *pDocSh, css::uno::Reference< css::container::XNamed > xNamed)
virtual rtl::Reference< ScNamedRangeObj > GetObjectByName_Impl(const OUString &aName) override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
XPropertySet.
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL setName(const OUString &aName) override
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
ScNamedRangeObj(rtl::Reference< ScNamedRangesObj > xParent, ScDocShell *pDocSh, OUString aNm, css::uno::Reference< css::container::XNamed > const &xSheet=css::uno::Reference< css::container::XNamed >())
virtual css::uno::Reference< css::table::XCellRange > SAL_CALL getReferredCells() override
XCellRangeReferrer.
rtl::Reference< ScNamedRangesObj > mxParent
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual void SAL_CALL setType(sal_Int32 nType) override
void Modify_Impl(const OUString *pNewName, const ScTokenArray *pNewTokens, const OUString *pNewContent, const ScAddress *pNewPos, const ScRangeData::Type *pNewType, const formula::FormulaGrammar::Grammar eGrammar)
virtual css::uno::Sequence< css::sheet::FormulaToken > SAL_CALL getTokens() override
XFormulaTokens.
virtual void SAL_CALL setContent(const OUString &aContent) override
virtual css::table::CellAddress SAL_CALL getReferencePosition() override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
ScRangeData * GetRangeData_Impl()
virtual OUString SAL_CALL getContent() override
XNamedRange.
virtual ~ScNamedRangeObj() override
virtual void SAL_CALL setTokens(const css::uno::Sequence< css::sheet::FormulaToken > &aTokens) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual sal_Int32 SAL_CALL getType() override
css::uno::Reference< css::container::XNamed > mxSheet
virtual OUString SAL_CALL getName() override
XNamed.
virtual void SAL_CALL setReferencePosition(const css::table::CellAddress &aReferencePosition) override
virtual ~ScNamedRangesObj() override
virtual void SAL_CALL outputList(const css::table::CellAddress &aOutputPosition) override
virtual void SAL_CALL addNewFromTitles(const css::table::CellRangeAddress &aSource, css::sheet::Border aBorder) override
virtual void SAL_CALL setActionLocks(sal_Int16 nLock) override
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
virtual ScRangeName * GetRangeName_Impl()=0
virtual sal_Bool SAL_CALL isActionLocked() override
XActionLockable.
virtual void SAL_CALL removeActionLock() override
virtual SCTAB GetTab_Impl()=0
virtual void SAL_CALL addNewByName(const OUString &aName, const OUString &aContent, const css::table::CellAddress &aPosition, sal_Int32 nType) override
XNamedRanges.
virtual void SAL_CALL addActionLock() override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
XPropertySet.
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
virtual sal_Int16 SAL_CALL resetActionLocks() override
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
virtual sal_Int32 SAL_CALL getCount() override
XIndexAccess.
ScNamedRangesObj(ScDocShell *pDocSh)
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual css::uno::Type SAL_CALL getElementType() override
XElementAccess.
void unlock()
called from the XActionLockable interface methods on final unlock
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
XEnumerationAccess.
bool mbModifyAndBroadcast
if true, adding new name or modifying existing one will set the document 'modified' and broadcast the...
virtual rtl::Reference< ScNamedRangeObj > GetObjectByIndex_Impl(sal_uInt16 nIndex)=0
virtual sal_Bool SAL_CALL hasElements() override
void lock()
called from the XActionLockable interface methods on initial locking
virtual void SAL_CALL removeByName(const OUString &aName) override
void GetName(OUString &rName) const
void SetIndex(sal_uInt16 nInd)
@ NAME_INVALID_BAD_STRING
const ScAddress & GetPos() const
sal_uInt16 GetIndex() const
static SC_DLLPUBLIC IsNameValidType IsNameValid(const OUString &rName, const ScDocument &rDoc)
SC_DLLPUBLIC OUString GetSymbol(const formula::FormulaGrammar::Grammar eGrammar=formula::FormulaGrammar::GRAM_DEFAULT) const
SC_DLLPUBLIC ScRangeData * findByUpperName(const OUString &rName)
ScRangePair * Find(const ScAddress &)
ScRangePairList * Clone() const
const ScRange & GetRange(sal_uInt16 n) const
static SC_DLLPUBLIC void ConvertToTokenSequence(const ScDocument &rDoc, css::uno::Sequence< css::sheet::FormulaToken > &rSequence, const ScTokenArray &rTokenArray)
static SC_DLLPUBLIC bool ConvertToTokenArray(ScDocument &rDoc, ScTokenArray &rTokenArray, const css::uno::Sequence< css::sheet::FormulaToken > &rSequence)
static void FillScRange(ScRange &rScRange, const css::table::CellRangeAddress &rApiRange)
static void FillApiRange(css::table::CellRangeAddress &rApiRange, const ScRange &rScRange)
const OUString & GetName() const
css::uno::Type const & get()
Sequence< sal_Int8 > aSeq
std::unique_ptr< sal_Int32[]> pData
#define SC_SIMPLE_SERVICE_INFO(ClassName, ClassNameAscii, ServiceAscii)
#define SC_IMPL_DUMMY_PROPERTY_LISTENER(ClassName)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
static o3tl::span< const SfxItemPropertyMapEntry > lcl_GetNamedRangesMap()
static o3tl::span< const SfxItemPropertyMapEntry > lcl_GetNamedRangeMap()
static bool lcl_UserVisibleName(const ScRangeData &rData)
constexpr OUStringLiteral SCNAMEDRANGEOBJ_SERVICE
constexpr OUStringLiteral SCLINKTARGET_SERVICE
constexpr OUStringLiteral SC_UNONAME_TOKENINDEX
constexpr OUStringLiteral SC_UNO_LINKDISPBIT
constexpr OUStringLiteral SC_UNONAME_ISSHAREDFMLA
constexpr OUStringLiteral SC_UNO_MODIFY_BROADCAST
constexpr OUStringLiteral SC_UNO_LINKDISPNAME