22 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
23 #include <com/sun/star/sheet/NamedRangeFlag.hpp>
24 #include <com/sun/star/awt/XBitmap.hpp>
25 #include <com/sun/star/beans/PropertyAttribute.hpp>
32 using ::com::sun::star::uno::Reference;
33 using ::com::sun::star::uno::Any;
41 #include <tokenarray.hxx>
43 #include <docfunc.hxx>
45 #include <unonames.hxx>
57 {
u"", 0, css::uno::Type(), 0, 0 }
59 return aNamedRangeMap_Impl;
67 {
u"", 0, css::uno::Type(), 0, 0 }
69 return aNamedRangesMap_Impl;
72 #define SCNAMEDRANGEOBJ_SERVICE "com.sun.star.sheet.NamedRange"
106 if ( rHint.
GetId() == SfxHintId::Dying )
142 bool bFound = rDoc.
GetTable(sName, nTab);
173 std::unique_ptr<ScRangeName> pNewRanges(
new ScRangeName(*pNames));
175 OUString aInsName = pOld->
GetName();
177 aInsName = *pNewName;
182 aContent = *pNewContent;
194 pNew =
new ScRangeData( rDoc, aInsName, *pNewTokens, aPos, nType );
196 pNew =
new ScRangeData( rDoc, aInsName, aContent, aPos, nType, eGrammar );
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);
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;
370 const OUString& rPropertyName,
const uno::Any& )
395 aRet <<= static_cast<sal_Int32>(pData->
GetIndex());
411 return "ScNamedRangeObj";
427 const uno::Sequence<sal_Int8 >& rId )
429 if ( isUnoTunnelId<ScNamedRangeObj>(rId) )
431 return sal::static_int_cast<sal_Int64>(
reinterpret_cast<sal_IntPtr
>(
this));
438 class theScNamedRangeObjUnoTunnelId :
public rtl::Static< UnoTunnelIdInit, theScNamedRangeObjUnoTunnelId> {};
443 return theScNamedRangeObjUnoTunnelId::get().getSeq();
447 mbModifyAndBroadcast(true),
465 if ( rHint.
GetId() == SfxHintId::Dying )
474 const OUString& aContent,
const table::CellAddress& aPosition,
478 ScAddress aPos( static_cast<SCCOL>(aPosition.Column), static_cast<SCROW>(aPosition.Row), aPosition.Sheet );
493 std::unique_ptr<ScRangeName> pNewRanges(
new ScRangeName( *pNames ));
497 if ( pNewRanges->insert(pNew) )
510 throw uno::RuntimeException();
514 sheet::Border aBorder )
519 bool bTop = ( aBorder == sheet::Border_TOP );
520 bool bLeft = ( aBorder == sheet::Border_LEFT );
521 bool bBottom = ( aBorder == sheet::Border_BOTTOM );
522 bool bRight = ( aBorder == sheet::Border_RIGHT );
549 std::unique_ptr<ScRangeName> pNewRanges(
new ScRangeName(*pNames));
550 pNewRanges->erase(*pData);
558 throw uno::RuntimeException();
564 ScAddress aPos( static_cast<SCCOL>(aOutputPosition.Column), static_cast<SCROW>(aOutputPosition.Row), aOutputPosition.Sheet );
588 for (
const auto& rName : *pNames)
601 throw lang::IndexOutOfBoundsException();
603 return uno::makeAny(xRange);
626 const OUString& rPropertyName,
const uno::Any& aValue )
650 uno::Reference< sheet::XNamedRange > xRange(GetObjectByName_Impl(aName));
652 throw container::NoSuchElementException();
654 return uno::makeAny(xRange);
666 uno::Sequence<OUString>
aSeq(nVisCount);
667 OUString* pAry = aSeq.getArray();
668 sal_uInt16 nVisPos = 0;
669 for (
const auto& rName : *pNames)
672 pAry[nVisPos++] = rName.second->GetName();
677 return uno::Sequence<OUString>(0);
722 if ( nLockCount == 1 )
734 if ( nLockCount > 0 )
737 if ( nLockCount == 0 )
753 if ( nLock == 0 && nLockCount > 0 )
757 if ( nLock > 0 && nLockCount == 0 )
769 if ( nLockCount > 0 )
798 for (
const auto& rName : *pNames)
863 for (
const auto& rName : *pNames)
908 if ( rHint.
GetId() == SfxHintId::Dying )
945 pEntry->GetRange(1) = *pData;
947 xNewList->Join( *pEntry,
true );
969 table::CellRangeAddress aRet;
987 table::CellRangeAddress aRet;
1003 pDocShell( pDocSh ),
1021 if ( rHint.
GetId() == SfxHintId::Dying )
1035 if ( pList && nIndex < pList->
size() )
1045 const table::CellRangeAddress& aDataArea )
1062 xNewList->Join(
ScRangePair( aLabelRange, aDataRange ) );
1085 if ( pOldList && nIndex >= 0 && nIndex < static_cast<sal_Int32>(pOldList->
size()) )
1089 xNewList->
Remove( nIndex );
1105 throw uno::RuntimeException();
1126 return pList->
size();
1134 uno::Reference< sheet::XLabelRange > xRange(
GetObjectByIndex_Impl(static_cast<sal_uInt16>(nIndex)));
1136 throw lang::IndexOutOfBoundsException();
1138 return uno::makeAny(xRange);
virtual OUString SAL_CALL getContent() override
XNamedRange.
virtual css::table::CellRangeAddress SAL_CALL getLabelArea() override
XLabelRange.
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
XPropertySet.
virtual css::table::CellAddress SAL_CALL getReferencePosition() override
virtual sal_Bool SAL_CALL hasElements() override
virtual void SAL_CALL addNewByName(const OUString &aName, const OUString &aContent, const css::table::CellAddress &aPosition, sal_Int32 nType) override
XNamedRanges.
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
XEnumerationAccess.
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
virtual ScRangeName * GetRangeName_Impl() override
bool CreateNames(const ScRange &rRange, CreateNameFlags nFlags, bool bApi, SCTAB nTab=-1)
virtual void SAL_CALL addNew(const css::table::CellRangeAddress &aLabelArea, const css::table::CellRangeAddress &aDataArea) override
XLabelRanges.
ScRangePair * GetData_Impl()
css::uno::Reference< css::container::XNamed > mxSheet
ScLabelRangesObj(ScDocShell *pDocSh, bool bCol)
virtual void SAL_CALL setDataArea(const css::table::CellRangeAddress &aDataArea) override
std::unique_ptr< ContentProperties > pData
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
XUnoTunnel.
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
ScRangePairList * GetColNameRanges()
#define SCLINKTARGET_SERVICE
void CompileColRowNameFormula()
sal_uInt16 GetIndex() const
void SetNewRangeNames(std::unique_ptr< ScRangeName > pNewRanges, bool bModifyDoc, SCTAB nTab)
rtl::Reference< ScNamedRangesObj > mxParent
SC_DLLPUBLIC void CompileHybridFormula()
Call this immediately after updating named ranges.
WeakReference< XInterface > mxParent
void Modify_Impl(const OUString *pNewName, const ScTokenArray *pNewTokens, const OUString *pNewContent, const ScAddress *pNewPos, const ScRangeData::Type *pNewType, const formula::FormulaGrammar::Grammar eGrammar)
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
ScRangeData * GetRangeData_Impl()
virtual ~ScLabelRangeObj() override
void SetDocumentModified()
const ContentProperties & rData
static const SfxItemPropertyMapEntry * lcl_GetNamedRangeMap()
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
virtual ScNamedRangeObj * GetObjectByIndex_Impl(sal_uInt16 nIndex) override
virtual ScNamedRangeObj * GetObjectByIndex_Impl(sal_uInt16 nIndex)=0
css::uno::Reference< css::container::XNamed > mxSheet
virtual css::uno::Reference< css::table::XCellRange > SAL_CALL getReferredCells() override
XCellRangeReferrer.
virtual void SAL_CALL removeByName(const OUString &aName) override
ScLabelRangeObj * GetObjectByIndex_Impl(size_t nIndex)
#define SC_UNONAME_ISSHAREDFMLA
virtual css::uno::Sequence< css::sheet::FormulaToken > SAL_CALL getTokens() override
XFormulaTokens.
virtual void SAL_CALL setTokens(const css::uno::Sequence< css::sheet::FormulaToken > &aTokens) override
ScNamedRangeObj(rtl::Reference< ScNamedRangesObj > const &xParent, ScDocShell *pDocSh, const OUString &rNm, css::uno::Reference< css::container::XNamed > const &xSheet=css::uno::Reference< css::container::XNamed >())
virtual ScRangeName * GetRangeName_Impl()=0
ScRange aRange
criterion to find range
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL removeActionLock() override
SC_DLLPUBLIC SCROW MaxRow() const
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
void SetNamedRangesLockCount(sal_Int16 nCount)
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
SC_DLLPUBLIC SCTAB GetTableCount() const
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
SC_DLLPUBLIC bool GetTable(const OUString &rName, SCTAB &rTab) const
virtual void SAL_CALL setContent(const OUString &aContent) override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
virtual css::uno::Type SAL_CALL getElementType() override
XElementAccess.
const OUString & GetName() const
void GetName(OUString &rName) const
virtual void SAL_CALL setType(sal_Int32 nType) override
#define SCNAMEDRANGEOBJ_SERVICE
virtual sal_Int32 SAL_CALL getType() override
SC_DLLPUBLIC ScRangeData * findByUpperName(const OUString &rName)
SC_DLLPUBLIC SCCOL MaxCol() const
ScRangePairList * Clone() const
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
static const SfxItemPropertyMapEntry * lcl_GetNamedRangesMap()
virtual OUString SAL_CALL getName() override
XNamed.
virtual sal_Int16 SAL_CALL resetActionLocks() override
SC_DLLPUBLIC void GetSymbol(OUString &rSymbol, const formula::FormulaGrammar::Grammar eGrammar=formula::FormulaGrammar::GRAM_DEFAULT) const
virtual ~ScNamedRangesObj() override
ScNamedRangesObj(ScDocShell *pDocSh)
void Modify_Impl(const ScRange *pLabel, const ScRange *pData)
virtual css::uno::Type SAL_CALL getElementType() override
XElementAccess.
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
XPropertySet.
virtual void SAL_CALL addNewFromTitles(const css::table::CellRangeAddress &aSource, css::sheet::Border aBorder) override
OUString uppercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
static SC_DLLPUBLIC void ConvertToTokenSequence(const ScDocument &rDoc, css::uno::Sequence< css::sheet::FormulaToken > &rSequence, const ScTokenArray &rTokenArray)
const ScRange & GetRange(sal_uInt16 n) const
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
static SC_DLLPUBLIC bool ConvertToTokenArray(ScDocument &rDoc, ScTokenArray &rTokenArray, const css::uno::Sequence< css::sheet::FormulaToken > &rSequence)
css::uno::Type const & get()
#define SC_SIMPLE_SERVICE_INFO(ClassName, ClassNameAscii, ServiceAscii)
bool mbModifyAndBroadcast
if true, adding new name or modifying existing one will set the document 'modified' and broadcast the...
virtual sal_Int32 SAL_CALL getCount() override
XIndexAccess.
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
void unlock()
called from the XActionLockable interface methods on final unlock
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
XEnumerationAccess.
bool HasType(Type nType) const
static bool lcl_UserVisibleName(const ScRangeData &rData)
virtual ~ScNamedRangeObj() override
#define SC_IMPL_DUMMY_PROPERTY_LISTENER(ClassName)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
ScLocalNamedRangesObj(ScDocShell *pDocSh, css::uno::Reference< css::container::XNamed > const &xNamed)
void AddUnoObject(SfxListener &rObject)
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
bool InsertNameList(const ScAddress &rStartPos, bool bApi)
virtual SCTAB GetTab_Impl() override
virtual void SAL_CALL setReferencePosition(const css::table::CellAddress &aReferencePosition) override
void SetIndex(sal_uInt16 nInd)
virtual css::table::CellRangeAddress SAL_CALL getDataArea() override
virtual sal_Bool SAL_CALL hasElements() override
SC_DLLPUBLIC sal_Int16 GetNamedRangesLockCount() const
const ScAddress & GetPos() const
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
ScRangePairList * GetRowNameRanges()
virtual void SAL_CALL outputList(const css::table::CellAddress &aOutputPosition) override
virtual SCTAB GetTab_Impl() override
virtual ~ScGlobalNamedRangesObj() override
virtual void SAL_CALL setName(const OUString &aName) override
ScLabelRangeObj(ScDocShell *pDocSh, bool bCol, const ScRange &rR)
#define SC_UNO_LINKDISPBIT
void lock()
called from the XActionLockable interface methods on initial locking
virtual void SAL_CALL removeByIndex(sal_Int32 nIndex) override
virtual void SAL_CALL setLabelArea(const css::table::CellRangeAddress &aLabelArea) override
really derive cell from range?
virtual void SAL_CALL addActionLock() override
virtual sal_Bool SAL_CALL isActionLocked() override
XActionLockable.
void RemoveUnoObject(SfxListener &rObject)
static SC_DLLPUBLIC const CharClass * getCharClassPtr()
virtual ScRangeName * GetRangeName_Impl() override
Sequence< sal_Int8 > aSeq
const ScDocument & GetDocument() const
virtual ~ScLocalNamedRangesObj() override
SC_DLLPUBLIC bool IsValidReference(ScRange &rRef) const
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual sal_Int32 SAL_CALL getCount() override
XIndexAccess.
virtual ScNamedRangeObj * GetObjectByName_Impl(const OUString &aName) override
static void FillApiRange(css::table::CellRangeAddress &rApiRange, const ScRange &rScRange)
#define SC_UNO_MODIFY_BROADCAST
static void FillScRange(ScRange &rScRange, const css::table::CellRangeAddress &rApiRange)
virtual ScNamedRangeObj * GetObjectByIndex_Impl(sal_uInt16 nIndex) override
virtual ~ScLabelRangesObj() override
virtual SCTAB GetTab_Impl()=0
#define SC_UNO_LINKDISPNAME
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
ScRangePair * Find(const ScAddress &)
ScRangePairListRef & GetRowNameRangesRef()
virtual ScNamedRangeObj * GetObjectByName_Impl(const OUString &aName) override
virtual void SAL_CALL setActionLocks(sal_Int16 nLock) override
ScGlobalNamedRangesObj(ScDocShell *pDocSh)
#define SC_UNONAME_TOKENINDEX
SC_DLLPUBLIC void PreprocessRangeNameUpdate()
ScRangePairListRef & GetColNameRangesRef()