29 #include <editeng/editeng.hxx>
48 #include <com/sun/star/awt/XBitmap.hpp>
49 #include <com/sun/star/util/CellProtection.hpp>
50 #include <com/sun/star/table/CellHoriJustify.hpp>
51 #include <com/sun/star/table/CellOrientation.hpp>
52 #include <com/sun/star/table/ShadowFormat.hpp>
53 #include <com/sun/star/table/TableBorder.hpp>
54 #include <com/sun/star/table/TableBorder2.hpp>
55 #include <com/sun/star/sheet/CellFlags.hpp>
56 #include <com/sun/star/sheet/FormulaResult.hpp>
57 #include <com/sun/star/beans/PropertyAttribute.hpp>
58 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
59 #include <com/sun/star/lang/Locale.hpp>
60 #include <com/sun/star/beans/TolerantPropertySetResultType.hpp>
61 #include <com/sun/star/beans/SetPropertyTolerantFailed.hpp>
62 #include <com/sun/star/text/WritingMode2.hpp>
63 #include <com/sun/star/text/textfield/Type.hpp>
64 #include <com/sun/star/sheet/XConditionalFormats.hpp>
91 #include <docfunc.hxx>
98 #include <stlsheet.hxx>
113 #include <globstr.hrc>
115 #include <unonames.hxx>
127 #include <tokenarray.hxx>
149 ScNamedEntry(
const OUString& rN,
const ScRange& rR) :
150 aName(rN), aRange(rR) {}
152 const OUString& GetName()
const {
return aName; }
153 const ScRange& GetRange()
const {
return aRange; }
265 {
u"", 0, css::uno::Type(), 0, 0 }
268 return &aCellsPropertySet;
376 {
u"", 0, css::uno::Type(), 0, 0 }
379 return &aRangePropertySet;
493 {
u"", 0, css::uno::Type(), 0, 0 }
496 return &aCellPropertySet;
608 {
u"", 0, css::uno::Type(), 0, 0 }
611 return &aColumnPropertySet;
721 {
u"", 0, css::uno::Type(), 0, 0 }
724 return &aRowPropertySet;
846 {
u"", 0, css::uno::Type(), 0, 0 }
849 return &aSheetPropertySet;
862 {
u"", 0, css::uno::Type(), 0, 0 }
864 return aEditPropertyMap_Impl;
869 return &aEditPropertySet;
875 #define SCCHARPROPERTIES_SERVICE "com.sun.star.style.CharacterProperties"
876 #define SCPARAPROPERTIES_SERVICE "com.sun.star.style.ParagraphProperties"
877 #define SCCELLPROPERTIES_SERVICE "com.sun.star.table.CellProperties"
878 #define SCCELLRANGE_SERVICE "com.sun.star.table.CellRange"
879 #define SCCELL_SERVICE "com.sun.star.table.Cell"
880 #define SCSHEETCELLRANGES_SERVICE "com.sun.star.sheet.SheetCellRanges"
881 #define SCSHEETCELLRANGE_SERVICE "com.sun.star.sheet.SheetCellRange"
882 #define SCSPREADSHEET_SERVICE "com.sun.star.sheet.Spreadsheet"
883 #define SCSHEETCELL_SERVICE "com.sun.star.sheet.SheetCell"
908 uno::Reference<beans::XPropertySetInfo> xInfo(rSource.getPropertySetInfo());
911 const uno::Sequence<beans::Property>
aSeq(xInfo->getProperties());
912 for (
const beans::Property& rProp :
aSeq)
914 OUString
aName(rProp.Name);
915 rDest.setPropertyValue( aName, rSource.getPropertyValue( aName ) );
923 throw std::out_of_range(
"empty range");
924 const ScRange & rFirst = rRanges[0];
930 if ( rRanges.
size() == 1 )
932 const ScRange & rRange = rRanges[0];
941 template<
typename BorderLineType>
942 const ::editeng::SvxBorderLine* lcl_getBorderLine(
959 return lcl_getBorderLine( rLine, rStruct);
965 return lcl_getBorderLine( rLine, rStruct);
969 template<
typename TableBorderType>
980 rInner.
SetValid( SvxBoxInfoItemValidFlags::TOP, rBorder.IsTopLineValid );
981 rInner.
SetValid( SvxBoxInfoItemValidFlags::BOTTOM, rBorder.IsBottomLineValid );
982 rInner.
SetValid( SvxBoxInfoItemValidFlags::LEFT, rBorder.IsLeftLineValid );
983 rInner.
SetValid( SvxBoxInfoItemValidFlags::RIGHT, rBorder.IsRightLineValid );
984 rInner.
SetValid( SvxBoxInfoItemValidFlags::HORI, rBorder.IsHorizontalLineValid );
985 rInner.
SetValid( SvxBoxInfoItemValidFlags::VERT, rBorder.IsVerticalLineValid );
986 rInner.
SetValid( SvxBoxInfoItemValidFlags::DISTANCE, rBorder.IsDistanceValid );
993 lcl_fillBoxItems( rOuter, rInner, rBorder);
998 lcl_fillBoxItems( rOuter, rInner, rBorder);
1014 template<
typename TableBorderItem>
1016 bool bInvalidateHorVerDist )
1026 rBorder.IsTopLineValid = rInner.
IsValid(SvxBoxInfoItemValidFlags::TOP);
1027 rBorder.IsBottomLineValid = rInner.
IsValid(SvxBoxInfoItemValidFlags::BOTTOM);
1028 rBorder.IsLeftLineValid = rInner.
IsValid(SvxBoxInfoItemValidFlags::LEFT);
1029 rBorder.IsRightLineValid = rInner.
IsValid(SvxBoxInfoItemValidFlags::RIGHT);
1030 rBorder.IsHorizontalLineValid = !bInvalidateHorVerDist && rInner.
IsValid(SvxBoxInfoItemValidFlags::HORI);
1031 rBorder.IsVerticalLineValid = !bInvalidateHorVerDist && rInner.
IsValid(SvxBoxInfoItemValidFlags::VERT);
1032 rBorder.IsDistanceValid = !bInvalidateHorVerDist && rInner.
IsValid(SvxBoxInfoItemValidFlags::DISTANCE);
1039 table::TableBorder aBorder;
1040 lcl_fillTableBorder( aBorder, rOuter, rInner, bInvalidateHorVerDist);
1047 table::TableBorder2 aBorder;
1048 lcl_fillTableBorder( aBorder, rOuter, rInner, bInvalidateHorVerDist);
1063 for (
size_t i = 0;
i < nCount; ++
i)
1065 ScRange const & rRange = rRanges[
i ];
1071 pUndoDoc->InitUndo( rDoc, nTab, nTab );
1073 pUndoDoc->AddUndoTab( nTab, nTab );
1079 aMark.SelectTable( nTab,
true );
1088 std::make_unique<ScUndoBorder>( pDocShell, rRanges, std::move(pUndoDoc), rOuter, rInner ) );
1091 for (
size_t i = 0;
i < nCount; ++
i )
1101 const uno::Sequence< uno::Sequence<uno::Any> >& aData )
1111 if ( !rDoc.
IsBlockEditable( nTab, nStartCol,nStartRow, nEndCol,nEndRow ) )
1117 sal_Int32 nCols = 0;
1118 sal_Int32 nRows =
aData.getLength();
1120 nCols =
aData[0].getLength();
1122 if ( nCols != nEndCol-nStartCol+1 || nRows != nEndRow-nStartRow+1 )
1132 pUndoDoc->InitUndo( rDoc, nTab, nTab );
1138 bool bError =
false;
1139 SCROW nDocRow = nStartRow;
1140 for (
const uno::Sequence<uno::Any>& rColSeq :
aData)
1142 if ( rColSeq.getLength() == nCols )
1144 SCCOL nDocCol = nStartCol;
1145 for (
const uno::Any& rElement : rColSeq)
1149 switch( rElement.getValueTypeClass() )
1151 case uno::TypeClass_VOID:
1154 rDoc.
SetError( nDocCol, nDocRow, nTab, FormulaError::NotAvailable );
1160 case uno::TypeClass_BYTE:
1161 case uno::TypeClass_SHORT:
1162 case uno::TypeClass_UNSIGNED_SHORT:
1163 case uno::TypeClass_LONG:
1164 case uno::TypeClass_UNSIGNED_LONG:
1165 case uno::TypeClass_FLOAT:
1166 case uno::TypeClass_DOUBLE:
1174 case uno::TypeClass_STRING:
1178 if ( !aUStr.isEmpty() )
1188 case uno::TypeClass_SEQUENCE:
1190 uno::Sequence< sheet::FormulaToken > aTokens;
1191 if ( rElement >>= aTokens )
1221 std::make_unique<ScUndoPaste>(
1222 &rDocShell,
ScRange(nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab),
1235 const uno::Sequence< uno::Sequence<OUString> >& aData,
1246 if ( !rDoc.
IsBlockEditable( nTab, nStartCol,nStartRow, nEndCol,nEndRow ) )
1252 sal_Int32 nCols = 0;
1253 sal_Int32 nRows =
aData.getLength();
1255 nCols =
aData[0].getLength();
1257 if ( nCols != nEndCol-nStartCol+1 || nRows != nEndRow-nStartRow+1 )
1267 pUndoDoc->InitUndo( rDoc, nTab, nTab );
1273 bool bError =
false;
1274 SCROW nDocRow = nStartRow;
1275 for (
const uno::Sequence<OUString>& rColSeq :
aData)
1277 if ( rColSeq.getLength() == nCols )
1279 SCCOL nDocCol = nStartCol;
1280 for (
const OUString& aText : rColSeq)
1282 ScAddress aPos( nDocCol, nDocRow, nTab );
1318 std::make_unique<ScUndoPaste>( &rDocShell,
1319 ScRange(nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab), aDestMark,
1374 OUString aTempString = aVal;
1375 bool bIsNumberFormat(pFormatter->
IsNumberFormat(aTempString, nNumFmt, fDummy));
1376 if ( bIsNumberFormat )
1377 aTempString =
"'" + aTempString;
1378 else if ( aTempString.startsWith(
"'") )
1382 if ( bEnglish || ( pFormatter->
GetType(nNumFmt) != SvNumFormatType::TEXT ) )
1383 aTempString =
"'" + aTempString;
1392 pDocShell( pDocSh ),
1394 bChartColAsHdr( false ),
1395 bChartRowAsHdr( false ),
1396 bCursorOnly( false ),
1397 bGotDataChangedHint( false ),
1398 aValueListeners( 0 )
1404 m_wThis = uno::Reference<uno::XInterface>(
1423 pDocShell( pDocSh ),
1426 bChartColAsHdr( false ),
1427 bChartRowAsHdr( false ),
1428 bCursorOnly( false ),
1429 bGotDataChangedHint( false ),
1430 aValueListeners( 0 )
1436 m_wThis = uno::Reference<uno::XInterface>(
1536 uno::Reference<uno::XInterface>
const xThis(
m_wThis);
1539 if (SfxHintId::Dying == rHint.
GetId())
1546 if (
auto pRefHint = dynamic_cast<const ScUpdateRefHint*>(&rHint) )
1549 std::unique_ptr<ScRangeList> pUndoRanges;
1554 pRefHint->GetDx(), pRefHint->GetDy(), pRefHint->GetDz() ) )
1558 && comphelper::getUnoTunnelImplementation<ScTableSheetObj>(xThis)
1578 else if (
auto pUndoHint = dynamic_cast<const ScUnoRefUndoHint*>(&rHint) )
1580 if ( pUndoHint->GetObjectId() ==
nObjectId )
1584 aRanges = pUndoHint->GetRanges();
1594 if ( nId == SfxHintId::Dying )
1603 lang::EventObject
aEvent;
1604 aEvent.Source.set(static_cast<cppu::OWeakObject*>(
this));
1605 for (uno::Reference<util::XModifyListener> & xValueListener :
aValueListeners)
1606 xValueListener->disposing( aEvent );
1608 aValueListeners.clear();
1614 else if ( nId == SfxHintId::DataChanged )
1629 lang::EventObject
aEvent;
1630 aEvent.Source.set(static_cast<cppu::OWeakObject*>(
this));
1635 for (
const uno::Reference<util::XModifyListener> & xValueListener :
aValueListeners)
1641 else if ( nId == SfxHintId::ScCalcAll )
1749 throw uno::RuntimeException();
1778 sal_uInt16& rItemWhich )
1786 rItemWhich = pEntry->
nWID;
1788 switch ( pEntry->
nWID )
1810 beans::PropertyState eRet = beans::PropertyState_DIRECT_VALUE;
1825 if ( eState == SfxItemState::SET )
1826 eRet = beans::PropertyState_DIRECT_VALUE;
1827 else if ( eState == SfxItemState::DEFAULT )
1828 eRet = beans::PropertyState_DEFAULT_VALUE;
1829 else if ( eState == SfxItemState::DONTCARE )
1830 eRet = beans::PropertyState_AMBIGUOUS_VALUE;
1833 OSL_FAIL(
"unknown ItemState");
1840 eRet = beans::PropertyState_DIRECT_VALUE;
1846 eRet = beans::PropertyState_DIRECT_VALUE;
1848 eRet = beans::PropertyState_AMBIGUOUS_VALUE;
1851 eRet = beans::PropertyState_DEFAULT_VALUE;
1860 throw uno::RuntimeException();
1863 sal_uInt16 nItemWhich = 0;
1870 const uno::Sequence<OUString>& aPropertyNames )
1876 uno::Sequence<beans::PropertyState> aRet(aPropertyNames.getLength());
1877 std::transform(aPropertyNames.begin(), aPropertyNames.end(), aRet.begin(),
1878 [
this, &rPropertyMap](
const auto& rName) -> beans::PropertyState {
1879 sal_uInt16 nItemWhich = 0;
1894 sal_uInt16 nItemWhich = 0;
1905 sal_uInt16 aWIDs[3];
1906 aWIDs[0] = nItemWhich;
1925 OUString aStyleName(
ScResId( STR_STYLENAME_STANDARD ) );
1952 switch ( pEntry->
nWID )
1959 aAny <<= static_cast<sal_Int16>(
TwipsToHMM(static_cast<const ScIndentItem&>(
1968 switch ( pEntry->
nWID )
1976 ScResId(STR_STYLENAME_STANDARD), SfxStyleFamily::Para );
2005 aAny <<= uno::Reference<sheet::XSheetConditionalEntries>(
2019 aAny <<= uno::Reference<beans::XPropertySet>(
2040 static uno::Reference<beans::XPropertySetInfo> aRef(
2047 sal_uInt16& rFirstItemId, sal_uInt16& rSecondItemId )
2049 rFirstItemId = rEntry.
nWID;
2053 switch ( rEntry.
nWID )
2063 sal_Int32 nIntVal = 0;
2064 if ( !(rValue >>= nIntVal) )
2065 throw lang::IllegalArgumentException();
2093 sal_Int16 nIntVal = 0;
2094 if ( !(rValue >>= nIntVal) )
2095 throw lang::IllegalArgumentException();
2103 sal_Int32 nRotVal = 0;
2104 if ( !(rValue >>= nRotVal) )
2105 throw lang::IllegalArgumentException();
2118 table::CellOrientation eOrient;
2119 if( rValue >>= eOrient )
2123 case table::CellOrientation_STANDARD:
2126 case table::CellOrientation_TOPBOTTOM:
2131 case table::CellOrientation_BOTTOMTOP:
2136 case table::CellOrientation_STACKED:
2155 const OUString& aPropertyName,
const uno::Any& aValue )
2160 throw uno::RuntimeException();
2165 throw beans::UnknownPropertyException(aPropertyName);
2192 sal_uInt16 nFirstItem, nSecondItem;
2196 if ( nWhich != nFirstItem && nWhich != nSecondItem )
2203 switch ( pEntry->
nWID )
2230 SfxItemSet aAttr = aEngine.GetEmptyItemSet();
2231 aEngine.SetText(aStr);
2236 aEngine.QuickSetAttribs(aAttr,
ESelection(0, 0, 0, aStr.getLength()));
2256 aStrVal, SfxStyleFamily::Para ));
2262 table::TableBorder aBorder;
2275 table::TableBorder2 aBorder2;
2290 uno::Reference<sheet::XSheetConditionalEntries> xInterface(aValue, uno::UNO_QUERY);
2294 comphelper::getUnoTunnelImplementation<ScTableConditionalFormat>( xInterface );
2319 auto pNew = std::make_unique<ScConditionalFormat>( 0, &rDoc );
2320 pFormat->
FillFormat( *pNew, rDoc, eGrammar );
2337 uno::Reference<beans::XPropertySet> xInterface(aValue, uno::UNO_QUERY);
2341 comphelper::getUnoTunnelImplementation<ScTableValidationObj>( xInterface );
2351 std::unique_ptr<ScValidationData> pNewData(
2372 throw uno::RuntimeException();
2377 throw beans::UnknownPropertyException(aPropertyName);
2394 switch ( pEntry->
nWID )
2405 GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
2406 rAny <<= static_cast<sal_Int32>(nOldFormat);
2410 rAny <<= static_cast<sal_Int16>(
TwipsToHMM(static_cast<const ScIndentItem&>(
2426 switch ( pEntry->
nWID )
2436 OUString aStyleName;
2439 aStyleName = pStyle->
GetName();
2441 aStyleName, SfxStyleFamily::Para );
2457 aMark.SelectTable( rFirst.
aStart.
Tab(), true );
2485 rAny <<= uno::Reference<sheet::XSheetConditionalEntries>(
2505 rAny <<= uno::Reference<beans::XPropertySet>(
2526 rAny <<= pPattern->
GetKey();
2533 const uno::Reference<beans::XPropertyChangeListener>& )
2537 throw uno::RuntimeException();
2539 OSL_FAIL(
"not implemented");
2543 const uno::Reference<beans::XPropertyChangeListener>& )
2547 throw uno::RuntimeException();
2549 OSL_FAIL(
"not implemented");
2553 const uno::Reference<beans::XVetoableChangeListener>&)
2555 OSL_FAIL(
"not implemented");
2559 const uno::Reference<beans::XVetoableChangeListener>&)
2561 OSL_FAIL(
"not implemented");
2567 const uno::Sequence< uno::Any >& aValues )
2571 sal_Int32
nCount(aPropertyNames.getLength());
2572 sal_Int32 nValues(aValues.getLength());
2574 throw lang::IllegalArgumentException();
2580 const OUString* pNames = aPropertyNames.getConstArray();
2586 for(i = 0; i < nCount; i++)
2592 pEntryArray[i] = pEntry;
2601 catch ( lang::IllegalArgumentException& )
2610 std::unique_ptr<ScPatternAttr> pOldPattern;
2611 std::unique_ptr<ScPatternAttr> pNewPattern;
2613 for(i = 0; i < nCount; i++)
2625 pOldPattern->GetItemSet().ClearInvalidItems();
2631 sal_uInt16 nFirstItem, nSecondItem;
2636 pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nFirstItem ) );
2638 pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nSecondItem ) );
2653 const uno::Sequence< OUString >& aPropertyNames )
2659 uno::Sequence<uno::Any> aRet(aPropertyNames.getLength());
2660 uno::Any* pProperties = aRet.getArray();
2661 for(sal_Int32
i = 0;
i < aPropertyNames.getLength();
i++)
2670 const uno::Reference< beans::XPropertiesChangeListener >& )
2672 OSL_FAIL(
"not implemented");
2677 OSL_FAIL(
"not implemented");
2681 const uno::Reference< beans::XPropertiesChangeListener >& )
2683 OSL_FAIL(
"not implemented");
2688 if ( pDocShell && (rHint.GetId() == SfxHintId::ScDataChanged))
2694 bGotDataChangedHint =
true;