20#include <config_feature_opencl.h>
35#include <svx/svxids.hrc>
37#include <LibreOfficeKit/LibreOfficeKitEnums.h>
39#include <officecfg/Office/Common.hxx>
40#include <officecfg/Office/Calc.hxx>
58#include <com/sun/star/beans/PropertyAttribute.hpp>
59#include <com/sun/star/util/Date.hpp>
60#include <com/sun/star/sheet/XNamedRanges.hpp>
61#include <com/sun/star/sheet/XLabelRanges.hpp>
62#include <com/sun/star/sheet/XSelectedSheetsSupplier.hpp>
63#include <com/sun/star/sheet/XUnnamedDatabaseRanges.hpp>
64#include <com/sun/star/i18n/XForbiddenCharacters.hpp>
65#include <com/sun/star/script/XLibraryContainer.hpp>
66#include <com/sun/star/lang/XInitialization.hpp>
67#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
68#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
69#include <com/sun/star/script/XInvocation.hpp>
70#include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
71#include <com/sun/star/beans/XFastPropertySet.hpp>
79#if HAVE_FEATURE_OPENCL
120#include <unonames.hxx>
131#include <strings.hrc>
190 return aDocOptPropertyMap_Impl;
205 return aColumnsPropertyMap_Impl;
222 return aRowsPropertyMap_Impl;
227constexpr OUStringLiteral
SCDOC_SERVICE =
u"com.sun.star.document.OfficeDocument";
250 sal_Int32 nNumProps= 10, nIdx = 0;
256 m_aUIProperties[nIdx++].Value <<= OUString(
"modules/scalc/ui/printeroptions.ui");
260 OUString aAppGroupname(
ScResId( SCSTR_PRINTOPT_PRODNAME ) );
269 ".HelpID:vcl:PrintDialog:IsSuppressEmptyPages:CheckBox",
270 "IsSuppressEmptyPages",
280 uno::Sequence< OUString > aChoices{
281 ScResId( SCSTR_PRINTOPT_ALLSHEETS ),
282 ScResId( SCSTR_PRINTOPT_SELECTEDSHEETS ),
283 ScResId( SCSTR_PRINTOPT_SELECTEDCELLS )};
284 uno::Sequence< OUString > aHelpIds{
285 ".HelpID:vcl:PrintDialog:PrintContent:ListBox"};
287 aHelpIds,
"PrintContent",
288 aChoices, nContent );
297 OUString aPrintRangeName(
"PrintRange" );
298 aChoices = {
ScResId( SCSTR_PRINTOPT_PRINTALLPAGES ),
ScResId( SCSTR_PRINTOPT_PRINTPAGES ) };
299 aHelpIds = {
".HelpID:vcl:PrintDialog:PrintRange:RadioButton:0",
300 ".HelpID:vcl:PrintDialog:PrintRange:RadioButton:1" };
301 uno::Sequence< OUString > aWidgetIds{
"rbAllPages",
"rbRangePages" };
311 ".HelpID:vcl:PrintDialog:PageRange:Edit",
312 "PageRange", OUString(), aPageRangeOpt);
317 uno::Sequence<OUString>(),
319 uno::Sequence<OUString>(),
321 uno::Sequence< sal_Bool >(),
324 assert(nIdx == nNumProps);
337 uno::Sequence<beans::PropertyValue> aUIProp;
338 if ( rPropValue.Value >>= aUIProp )
340 for (
auto& rProp : asNonConstRange(aUIProp))
342 OUString
aName = rProp.Name;
343 if (
aName ==
"Property" )
345 beans::PropertyValue aPropertyValue;
346 if ( rProp.Value >>= aPropertyValue )
348 if ( aPropertyValue.Name ==
"PrintContent" )
350 aPropertyValue.Value <<= nContent;
351 rProp.Value <<= aPropertyValue;
353 else if ( aPropertyValue.Name ==
"IsSuppressEmptyPages" )
355 aPropertyValue.Value <<= bSuppress;
356 rProp.Value <<= aPropertyValue;
361 rPropValue.Value <<= aUIProp;
405 xNumberAgg->setDelegator(uno::Reference<uno::XInterface>());
421 uno::Reference<util::XNumberFormatsSupplier> xFormatter(
424 xNumberAgg.set(uno::Reference<uno::XAggregation>( xFormatter, uno::UNO_QUERY ));
429 xFormatter =
nullptr;
499 constexpr size_t nMaxIter = 5;
502 pViewShell && nIter < nMaxIter;
505 if (pViewShell->GetDocId() != rDocId)
521 int nOutputWidth,
int nOutputHeight,
522 int nTilePosX,
int nTilePosY,
541 pViewData = pActiveViewData;
556 pGridWindow->
PaintTile( rDevice, nOutputWidth, nOutputHeight,
557 nTilePosX, nTilePosY, nTileWidth, nTileHeight );
564 Size aOutputSize(nOutputWidth, nOutputHeight);
605 const bool bIsSelected =
false;
608 OUString aPartInfo =
"{ \"visible\": \"" +
609 OUString::number(
static_cast<unsigned int>(bIsVisible)) +
610 "\", \"selected\": \"" +
611 OUString::number(
static_cast<unsigned int>(bIsSelected)) +
612 "\", \"rtllayout\": \"" +
613 OUString::number(
static_cast<unsigned int>(bIsRTLLayout)) +
636 return (pViewData->
GetDocument().
GetHashCode(nPart, nHashCode) ? OUString::number(nHashCode) : OUString());
671 const double fPPTX = pViewData->
GetPPTX();
672 const double fPPTY = pViewData->
GetPPTY();
674 auto GetColWidthPx = [pThisDoc, fPPTX, nTab](
SCCOL nCol) {
675 const sal_uInt16 nSize = pThisDoc->
GetColWidth(nCol, nTab);
682 if (nDocWidthPixel > 0 && nDocHeightPixel > 0)
685 aSize.
setWidth(nDocWidthPixel / fPPTX);
686 aSize.
setHeight(nDocHeightPixel / fPPTY);
716 aSize =
Size(nEndCol, nEndRow);
748 nButtons, nModifier, pViewData->
GetPPTX(),
749 pViewData->
GetPPTY(), bDrawNegativeX))
752 Point aPointTwip(nX, nY);
756 Point aPointHMMDraw(bDrawNegativeX ? -aPointHMM.X() : aPointHMM.X(), aPointHMM.Y());
772 aData.setLogicPosition(aPointHMM);
775 case LOK_MOUSEEVENT_MOUSEBUTTONDOWN:
776 aEvent = VclEventId::WindowMouseButtonDown;
778 case LOK_MOUSEEVENT_MOUSEBUTTONUP:
779 aEvent = VclEventId::WindowMouseButtonUp;
781 case LOK_MOUSEEVENT_MOUSEMOVE:
782 aEvent = VclEventId::WindowMouseMove;
808 bool bHandled =
false;
822 case LOK_SETTEXTSELECTION_START:
825 case LOK_SETTEXTSELECTION_END:
828 case LOK_SETTEXTSELECTION_RESET:
838 else if (pDrawView && pDrawView->
IsTextEdit())
847 case LOK_SETTEXTSELECTION_START:
850 case LOK_SETTEXTSELECTION_END:
853 case LOK_SETTEXTSELECTION_RESET:
880 uno::Reference<datatransfer::XTransferable> xTransferable;
884 if (
ScEditShell * pShell =
dynamic_cast<ScEditShell*
>( pViewData->GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) ) )
886 else if (
nullptr !=
dynamic_cast<ScDrawTextObjectBar*
>( pViewData->GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) ))
888 ScDrawView* pView = pViewData->GetScDrawView();
893 else if (
ScDrawShell * pDrawShell =
dynamic_cast<ScDrawShell*
>( pViewData->GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) ) )
894 xTransferable = pDrawShell->GetDrawView()->CopyToTransferable();
896 xTransferable = pViewData->GetViewShell()->CopyToTransferable();
899 if (!xTransferable.is())
902 return xTransferable;
919 double fPPTX = pViewData->
GetPPTX();
920 double fPPTY = pViewData->
GetPPTY();
927 int nPixelX = nX * fPPTX;
928 int nPixelY = nY * fPPTY;
932 case LOK_SETGRAPHICSELECTION_START:
940 case LOK_SETGRAPHICSELECTION_END:
1032 constexpr double fEps = 1
E-08;
1034 if (pViewData->
GetZoomX() == newZoomX && pViewData->
GetZoomY() == newZoomY && fDeltaPPTX < fEps && fDeltaPPTY < fEps)
1037 pViewData->
SetZoom(newZoomX, newZoomY,
true);
1044 pDrawView->resetGridOffsetsForAllSdrPageViews();
1061 bool bFiltered,
bool bGroups)
1086 rJsonWriter.
put(
"commandName",
".uno:CellCursor");
1096 return PointerStyle::Arrow;
1100 return PointerStyle::Arrow;
1110 pChangeTrack->GetChangeTrackInfo(rJson);
1127 comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs))
1153 std::vector<sc::NoteEntry> aNotes;
1156 auto commentsNode = rJsonWriter.
startArray(
"comments");
1161 rJsonWriter.
put(
"id", aNote.mpNote->GetId());
1162 rJsonWriter.
put(
"tab", aNote.maPos.Tab());
1163 rJsonWriter.
put(
"author", aNote.mpNote->GetAuthor());
1164 rJsonWriter.
put(
"dateTime", aNote.mpNote->GetDate());
1165 rJsonWriter.
put(
"text", aNote.mpNote->GetText());
1173 SCCOL nX = aNote.maPos.Col();
1174 SCROW nY = aNote.maPos.Row();
1175 Point aScrPos = pViewData->GetScrPos(nX, nY, pViewData->GetActivePart(),
true);
1178 pViewData->GetMergeSizePixel(nX, nY, nSizeXPix, nSizeYPix);
1180 double fPPTX = pViewData->GetPPTX();
1181 double fPPTY = pViewData->GetPPTY();
1183 Size(nSizeXPix / fPPTX, nSizeYPix / fPPTY));
1197 std::vector<sc::NoteEntry> aNotes;
1200 auto commentsNode = rJsonWriter.
startArray(
"commentsPos");
1205 rJsonWriter.
put(
"id", aNote.mpNote->GetId());
1206 rJsonWriter.
put(
"tab", aNote.maPos.Tab());
1214 SCCOL nX = aNote.maPos.Col();
1215 SCROW nY = aNote.maPos.Row();
1216 Point aScrPos = pViewData->GetScrPos(nX, nY, pViewData->GetActivePart(),
true);
1219 pViewData->GetMergeSizePixel(nX, nY, nSizeXPix, nSizeYPix);
1221 double fPPTX = pViewData->GetPPTX();
1222 double fPPTY = pViewData->GetPPTY();
1224 Size(nSizeXPix / fPPTX, nSizeYPix / fPPTY));
1237 assert(!rFunctionName.isEmpty());
1249 SC_MOD()->SetAppOptions(aAppOptions);
1251 for (
const beans::PropertyValue& rValue : rArguments)
1253 if (rValue.Name ==
".uno:SpellOnline" && rValue.Value.has<
bool>())
1265 SC_MOD()->SetInputOptions(aInputOptions);
1273 officecfg::Office::Common::Save::Document::WarnAlienFormat::set(
false, xChanges);
1308 aRet =
xNumberAgg->queryAggregation( rType );
1326 static const uno::Sequence<uno::Type>
aTypes = [&]()
1328 uno::Sequence<uno::Type> aAggTypes;
1336 aAggTypes = (*xNumProv)->getTypes();
1342 uno::Sequence<uno::Type>
1367 return css::uno::Sequence<sal_Int8>();
1375 if (
nId == SfxHintId::Dying )
1381 comphelper::getFromUnoTunnel<SvNumberFormatsSupplierObj>(
1382 uno::Reference<util::XNumberFormatsSupplier>(
xNumberAgg, uno::UNO_QUERY) );
1390 else if (
nId == SfxHintId::DataChanged )
1434 return css::uno::Reference< ::css::chart2::data::XDataProvider > (
1455 for (
const beans::PropertyValue& rProp : rOptions)
1457 const OUString & rPropName = rProp.Name;
1461 uno::Reference<awt::XDevice> xRenderDevice(rProp.Value, uno::UNO_QUERY);
1462 if ( xRenderDevice.is() )
1483 sal_Int32 nNumeric = 0;
1485 bool bRangeValid =
false;
1486 bool bRectValid =
false;
1494 rTargetRange = aAddress;
1503 ( nNumeric =
rTarget.toInt32() ) > 0 && nNumeric <= rDoc.
MaxRow()+1 )
1506 rTargetRange =
ScAddress( 0,
static_cast<SCROW>(nNumeric-1), nSourceTab );
1523 for (
SCTAB i=0;
i<nTabCount && !bRangeValid;
i++)
1526 OSL_ENSURE(pPage,
"Page ?");
1531 while (
pObject && !bRangeValid)
1535 rTargetRect =
pObject->GetLogicRect();
1536 rTargetRange = rDoc.
GetRange(
i, rTargetRect );
1537 bRangeValid = bRectValid =
true;
1545 if ( bRangeValid && !bRectValid )
1557 const uno::Sequence< beans::PropertyValue >& rOptions,
1560 bool& rbRenderToGraphic )
const
1562 OSL_ENSURE( !rMark.
IsMarked() && !rMark.
IsMultiMarked(),
"FillRenderMarkData: MarkData must be empty" );
1563 OSL_ENSURE(
pDocShell,
"FillRenderMarkData: DocShell must be set" );
1567 uno::Reference<frame::XController> xView;
1570 bool bSelectedSheetsOnly =
false;
1571 bool bSuppressEmptyPages =
true;
1573 bool bHasPrintContent =
false;
1574 sal_Int32 nPrintContent = 0;
1575 sal_Int32 nPrintRange = 0;
1576 sal_Int32 nEOContent = 0;
1577 OUString aPageRange;
1579 for(
const auto& rOption : rOptions )
1581 if ( rOption.Name ==
"IsOnlySelectedSheets" )
1583 rOption.Value >>= bSelectedSheetsOnly;
1585 else if ( rOption.Name ==
"IsSuppressEmptyPages" )
1587 rOption.Value >>= bSuppressEmptyPages;
1589 else if ( rOption.Name ==
"PageRange" )
1591 rOption.Value >>= aPageRange;
1593 else if ( rOption.Name ==
"PrintRange" )
1595 rOption.Value >>= nPrintRange;
1597 else if ( rOption.Name ==
"EvenOdd" )
1599 rOption.Value >>= nEOContent;
1601 else if ( rOption.Name ==
"PrintContent" )
1603 bHasPrintContent =
true;
1604 rOption.Value >>= nPrintContent;
1606 else if ( rOption.Name ==
"View" )
1608 rOption.Value >>= xView;
1610 else if ( rOption.Name ==
"RenderToGraphic" )
1612 rOption.Value >>= rbRenderToGraphic;
1617 if ( bHasPrintContent )
1618 bSelectedSheetsOnly = ( nPrintContent != 0 );
1620 uno::Reference<uno::XInterface> xInterface(aSelection, uno::UNO_QUERY);
1621 if ( xInterface.is() )
1623 ScCellRangesBase* pSelObj =
dynamic_cast<ScCellRangesBase*
>( xInterface.get() );
1624 uno::Reference< drawing::XShapes > xShapes( xInterface, uno::UNO_QUERY );
1625 if ( pSelObj && pSelObj->GetDocShell() ==
pDocShell )
1627 bool bSheet = (
dynamic_cast<ScTableSheetObj*
>( pSelObj ) !=
nullptr );
1628 bool bCursor = pSelObj->IsCursorOnly();
1629 const ScRangeList& rRanges = pSelObj->GetRangeList();
1647 if ( bCursor || bSheet )
1660 else if( xShapes.is() )
1664 uno::Reference< drawing::XShape > xShape( xShapes->getByIndex(0), uno::UNO_QUERY );
1681 else if ( comphelper::getFromUnoTunnel<ScModelObj>( xInterface ) ==
this )
1687 for (
SCTAB nTab = 0; nTab < nTabCount; nTab++)
1696 uno::Reference<sheet::XSelectedSheetsSupplier> xSelectedSheets(xView, uno::UNO_QUERY);
1697 if (bSelectedSheetsOnly &&
pDocShell && xSelectedSheets.is())
1699 const uno::Sequence<sal_Int32> aSelected = xSelectedSheets->getSelectedSheets();
1702 for (
const auto& rSelected : aSelected)
1704 SCTAB nSelected =
static_cast<SCTAB>(rSelected);
1706 aSelectedTabs.insert(nSelected);
1717 if ( nPrintRange == 1 )
1718 rPagesStr = aPageRange;
1726 const uno::Sequence<beans::PropertyValue>& rOptions)
1731 throw lang::DisposedException( OUString(),
1732 static_cast< sheet::XSpreadsheetDocument*
>(
this) );
1738 bool bRenderToGraphic =
false;
1739 if ( !
FillRenderMarkData( aSelection, rOptions, aMark, aStatus, aPagesStr, bRenderToGraphic ) )
1755 sal_Int32 nContent = 0;
1756 sal_Int32 nEOContent = 0;
1757 bool bSinglePageSheets =
false;
1758 for (
const auto& rValue : rOptions)
1760 if ( rValue.Name ==
"PrintRange" )
1762 rValue.Value >>= nContent;
1764 else if ( rValue.Name ==
"SinglePageSheets" )
1766 rValue.Value >>= bSinglePageSheets;
1768 else if ( rValue.Name ==
"EvenOdd" )
1770 rValue.Value >>= nEOContent;
1774 if (bSinglePageSheets)
1779 bool bIsPrintEvenPages = (nEOContent != 1 && nContent == 0) || nContent != 0;
1780 bool bIsPrintOddPages = (nEOContent != 2 && nContent == 0) || nContent != 0;
1782 for ( sal_Int32 nPage = 1; nPage <= nPages; nPage++ )
1788 sal_Int32 nSelectCount =
static_cast<sal_Int32
>(
maValidPages.size() );
1790 if ( nEOContent == 1 || nEOContent == 2 )
1791 return nSelectCount;
1793 if ( !aPagesStr.isEmpty() )
1796 nSelectCount = aRangeEnum.
size();
1798 return (nSelectCount > 0) ? nSelectCount : 1;
1801static sal_Int32
lcl_GetRendererNum( sal_Int32 nSelRenderer, std::u16string_view rPagesStr, sal_Int32 nTotalPages )
1803 if ( rPagesStr.empty() )
1804 return nSelRenderer;
1809 for ( ; nSelRenderer > 0 && aIter != aEnd; --nSelRenderer )
1821 const uno::Any& aSelection,
const uno::Sequence<beans::PropertyValue>& rOptions )
1826 throw lang::DisposedException( OUString(),
1827 static_cast< sheet::XSpreadsheetDocument*
>(
this) );
1835 bool bRenderToGraphic =
false;
1836 bool bSinglePageSheets =
false;
1837 if (
FillRenderMarkData( aSelection, rOptions, aMark, aStatus, aPagesStr, bRenderToGraphic ) )
1846 for (
const auto& rValue : rOptions)
1848 if ( rValue.Name ==
"SinglePageSheets" )
1850 rValue.Value >>= bSinglePageSheets;
1855 if (bSinglePageSheets)
1860 if ( nRenderer < 0 )
1862 if ( nSelRenderer != 0 )
1863 throw lang::IllegalArgumentException();
1867 awt::Size aPageSize;
1875 aPageSize.Width = aMMRect.
GetWidth();
1880 SCTAB const nCurTab = 0;
1903 if (bSinglePageSheets)
1904 nTab = nSelRenderer;
1912 const ScRange* pSelRange =
nullptr;
1913 if ( bSinglePageSheets )
1926 table::CellRangeAddress aRangeAddress( nTab,
1934 const awt::Point aCalcPagePos(aMMRect.
Left(), aMMRect.
Top());
1936 uno::Sequence<beans::PropertyValue> aSequence
1956 pSelRange = &aRange;
1959 awt::Size aPageSize;
1960 bool bWasCellRange =
false;
1964 bWasCellRange =
true;
1965 aCellRange = aRange;
1969 aPageSize.Width = aMMRect.
GetWidth();
1974 std::unique_ptr<ScPrintFunc, o3tl::default_delete<ScPrintFunc>> pPrintFunc;
1980 pPrintFunc->SetRenderFlag(
true );
1982 sal_Int32 nContent = 0;
1983 sal_Int32 nEOContent = 0;
1984 for (
const auto& rValue : rOptions)
1986 if ( rValue.Name ==
"PrintRange" )
1988 rValue.Value >>= nContent;
1990 else if ( rValue.Name ==
"EvenOdd" )
1992 rValue.Value >>= nEOContent;
1999 bool bOddOrEven = (nContent == 0 && nEOContent == 1) || (nContent == 1 && nEOContent == 2);
2006 aPage.
Select( nRenderer+1 );
2011 (void)pPrintFunc->DoPrint( aPage, nTabStart, nDisplayStart,
false,
nullptr );
2013 bWasCellRange = pPrintFunc->GetLastSourceRange( aCellRange );
2014 Size aTwips = pPrintFunc->GetPageSize();
2027 uno::Sequence<beans::PropertyValue> aSequence(nPropCount);
2028 beans::PropertyValue* pArray = aSequence.getArray();
2030 pArray[0].Value <<= aPageSize;
2033 pArray[1].Value <<=
true;
2034 if ( bWasCellRange )
2036 table::CellRangeAddress aRangeAddress( nTab,
2044 const awt::Point aCalcPagePos(aMMRect.
Left(), aMMRect.
Top());
2047 pArray[2].Value <<= aRangeAddress;
2049 pArray[3].Value <<= aCalcPageSize;
2051 pArray[4].Value <<= aCalcPagePos;
2063 const uno::Sequence<beans::PropertyValue>& rOptions )
2068 throw lang::DisposedException( OUString(),
2069 static_cast< sheet::XSpreadsheetDocument*
>(
this) );
2075 bool bRenderToGraphic =
false;
2076 bool bSinglePageSheets =
false;
2077 if ( !
FillRenderMarkData( aSelection, rOptions, aMark, aStatus, aPagesStr, bRenderToGraphic ) )
2078 throw lang::IllegalArgumentException();
2086 for (
const auto& rValue : rOptions)
2088 if ( rValue.Name ==
"SinglePageSheets" )
2090 rValue.Value >>= bSinglePageSheets;
2095 if (bSinglePageSheets)
2099 if ( nRenderer < 0 )
2100 throw lang::IllegalArgumentException();
2104 throw lang::IllegalArgumentException();
2109 const ScRange* pSelRange =
nullptr;
2110 if ( bSinglePageSheets )
2112 awt::Size aPageSize;
2115 rDoc.
GetDataStart( nSelRenderer, nStartCol, nStartRow );
2127 aPageSize.Width = aMMRect.
GetWidth();
2132 if (nVisTab != nSelRenderer)
2134 nVisTab = nSelRenderer;
2145 pSelRange = &aRange;
2159 const double nPrintFactor = 1.0;
2168 struct DrawViewKeeper
2170 std::unique_ptr<FmFormView> mpDrawView;
2176 mpDrawView->HideSdrPage();
2192 aDrawViewKeeper.mpDrawView.reset(
new FmFormView(
2195 aDrawViewKeeper.mpDrawView->ShowSdrPage(aDrawViewKeeper.mpDrawView->GetModel()->GetPage(nTab));
2196 aDrawViewKeeper.mpDrawView->SetPrintPreview();
2203 std::unique_ptr<ScPrintFunc, o3tl::default_delete<ScPrintFunc>> pPrintFunc;
2210 pPrintFunc->SetDrawView( aDrawViewKeeper.mpDrawView.get() );
2211 pPrintFunc->SetRenderFlag(
true );
2213 pPrintFunc->SetExclusivelyDrawOleAndDrawObjects();
2215 sal_Int32 nContent = 0;
2216 sal_Int32 nEOContent = 0;
2217 for (
const auto& rValue : rOptions)
2219 if ( rValue.Name ==
"PrintRange" )
2221 rValue.Value >>= nContent;
2223 else if ( rValue.Name ==
"EvenOdd" )
2225 rValue.Value >>= nEOContent;
2232 bool bOddOrEven = (nContent == 0 && nEOContent == 1) || (nContent == 0 && nEOContent == 2);
2239 aPage.
Select( nRenderer+1 );
2245 if ( nRenderer == nTabStart )
2259 sal_Int32 nDestID = pPDFData->
CreateDest( aArea );
2261 rDoc.
GetName( nTab, aTabName );
2270 rDoc.
GetName( nTab, aTabName );
2276 (void)pPrintFunc->DoPrint( aPage, nTabStart, nDisplayStart,
true,
nullptr );
2291 std::vector< vcl::PDFExtOutDevBookmarkEntry >& rBookmarks = pPDFData->
GetBookmarks();
2292 for (
const auto& rBookmark : rBookmarks )
2294 OUString aBookmark = rBookmark.aBookmark;
2295 if ( aBookmark.toChar() ==
'#' )
2299 OUString aTarget( aBookmark.copy( 1 ) );
2303 bool bIsSheet =
false;
2304 bool bValid =
lcl_ParseTarget( aTarget, aTargetRange, aTargetRect, bIsSheet, rDoc, nTab );
2308 sal_Int32 nPage = -1;
2324 nPage = aLocation.
nPage;
2346 if ( nX1 > aLocationPixel.
Right() ) nX1 = aLocationPixel.
Right();
2347 if ( nX2 > aLocationPixel.
Right() ) nX2 = aLocationPixel.
Right();
2348 if ( nY1 > aLocationPixel.
Bottom() ) nY1 = aLocationPixel.
Bottom();
2349 if ( nY2 > aLocationPixel.
Bottom() ) nY2 = aLocationPixel.
Bottom();
2365 pPDFData->
SetLinkURL( rBookmark.nLinkId, aBookmark );
2386 bool bLocked =
false;
2416 sal_uInt16 nRet = 0;
2456 OSL_FAIL(
"no DocShell");
2470 OSL_FAIL(
"no DocShell");
2480 OSL_FAIL(
"no DocShell");
2486 bool bEnabled(bEnabledIn);
2499 OSL_FAIL(
"no DocShell");
2522 throw lang::IllegalArgumentException();
2532 OSL_FAIL(
"no DocShell");
2544 OSL_FAIL(
"no DocShell");
2551 const table::CellAddress& aFormulaPosition,
2552 const table::CellAddress& aVariablePosition,
2553 const OUString& aGoalValue )
2556 sheet::GoalResult aResult;
2557 aResult.Divergence = DBL_MAX;
2562 double fValue = 0.0;
2563 bool bFound = rDoc.
Solver(
2564 static_cast<SCCOL>(aFormulaPosition.Column),
static_cast<SCROW>(aFormulaPosition.Row), aFormulaPosition.Sheet,
2565 static_cast<SCCOL>(aVariablePosition.Column),
static_cast<SCROW>(aVariablePosition.Row), aVariablePosition.Sheet,
2566 aGoalValue, fValue );
2567 aResult.Result = fValue;
2569 aResult.Divergence = 0.0;
2586 pNew->SetParam( *pParam );
2592 const uno::Reference<sheet::XConsolidationDescriptor>& xDescriptor )
2601 xImpl->setFunction( xDescriptor->getFunction() );
2602 xImpl->setSources( xDescriptor->getSources() );
2603 xImpl->setStartOutputPosition( xDescriptor->getStartOutputPosition() );
2604 xImpl->setUseColumnHeaders( xDescriptor->getUseColumnHeaders() );
2605 xImpl->setUseRowHeaders( xDescriptor->getUseRowHeaders() );
2606 xImpl->setInsertLinks( xDescriptor->getInsertLinks() );
2642 uno::Sequence< beans::PropertyValue >
aSeq{
2660 static uno::Reference<beans::XPropertySetInfo> aRef(
2666 const OUString& aPropertyName,
const uno::Any& aValue )
2688 bHardRecalc =
false;
2692 lang::Locale aLocale;
2693 if ( aValue >>= aLocale )
2704 if ( aValue >>= sCodeName )
2709 lang::Locale aLocale;
2710 if ( aValue >>= aLocale )
2720 lang::Locale aLocale;
2721 if ( aValue >>= aLocale )
2737 pBindings->
Invalidate( SID_FM_OPEN_READONLY );
2747 pBindings->
Invalidate( SID_FM_AUTOCONTROLFOCUS );
2759 ? officecfg::Office::Common::Undo::Steps::get() : 0);
2765 bool bChangeAllowed =
true;
2766 if (!bRecordChangesEnabled)
2787 else if ( aPropertyName ==
"BuildId" )
2791 else if ( aPropertyName ==
"SavedObject" )
2794 aValue >>= aObjName;
2795 if ( !aObjName.isEmpty() )
2803 if ( aNewOpt != rOldOpt )
2832 lang::Locale aLocale;
2846 lang::Locale aLocale;
2855 lang::Locale aLocale;
2900 aRet <<= bOpenInDesign;
2907 aRet <<= bAutoControlFocus;
2932 aRet <<= OUString(
"ThisExcelDoc" );
2974 aRet <<= uno::Reference< awt::XDevice >( pXDev );
2976 else if ( aPropertyName ==
"BuildId" )
2980 else if ( aPropertyName ==
"InternalDocument" )
2998 OUString const & aServiceSpecifier,
2999 css::
uno::Sequence<css::
uno::Any> const * arguments)
3003 uno::Reference<uno::XInterface> xRet;
3005 if (
nType != ServiceType::INVALID )
3011 case ServiceType::GRADTAB: xRet.set(xDrawGradTab);
break;
3012 case ServiceType::HATCHTAB: xRet.set(xDrawHatchTab);
break;
3013 case ServiceType::BITMAPTAB: xRet.set(xDrawBitmapTab);
break;
3014 case ServiceType::TRGRADTAB: xRet.set(xDrawTrGradTab);
break;
3015 case ServiceType::MARKERTAB: xRet.set(xDrawMarkerTab);
break;
3016 case ServiceType::DASHTAB: xRet.set(xDrawDashTab);
break;
3017 case ServiceType::CHDATAPROV: xRet.set(xChartDataProv);
break;
3018 case ServiceType::VBAOBJECTPROVIDER: xRet.set(xObjProvider);
break;
3025 (
nType != ServiceType::CHDATAPROV ||
3026 ( pDocShell->GetCreateMode() != SfxObjectCreateMode::INTERNAL ));
3031 if ( !xRet.is() && bCreate )
3038 case ServiceType::GRADTAB: xDrawGradTab.set(xRet);
break;
3039 case ServiceType::HATCHTAB: xDrawHatchTab.set(xRet);
break;
3040 case ServiceType::BITMAPTAB: xDrawBitmapTab.set(xRet);
break;
3041 case ServiceType::TRGRADTAB: xDrawTrGradTab.set(xRet);
break;
3042 case ServiceType::MARKERTAB: xDrawMarkerTab.set(xRet);
break;
3043 case ServiceType::DASHTAB: xDrawDashTab.set(xRet);
break;
3044 case ServiceType::CHDATAPROV: xChartDataProv.set(xRet);
break;
3045 case ServiceType::VBAOBJECTPROVIDER: xObjProvider.set(xRet);
break;
3057 xRet = arguments ==
nullptr
3060 aServiceSpecifier, *arguments);
3063 catch ( lang::ServiceNotRegisteredException & )
3070 uno::Reference<drawing::XShape> xShape( xRet, uno::UNO_QUERY );
3082 const OUString& aServiceSpecifier )
3085 return create(aServiceSpecifier,
nullptr);
3089 const OUString& ServiceSpecifier,
3090 const uno::Sequence<uno::Any>& aArgs )
3095 uno::Reference<uno::XInterface> xInt(
create(ServiceSpecifier, &aArgs));
3097 if ( aArgs.hasElements() )
3101 uno::Reference<lang::XInitialization> xInit( xInt, uno::UNO_QUERY );
3103 xInit->initialize( aArgs );
3120 return "ScModelObj";
3139 const uno::Sequence<sal_Int8 >& rId )
3141 if ( comphelper::isUnoTunnelId<ScModelObj>(rId) )
3146 if ( comphelper::isUnoTunnelId<SfxObjectShell>(rId) )
3162 if(
auto xTunnelAgg =
o3tl::tryAccess<uno::Reference<lang::XUnoTunnel>>(
3165 return (*xTunnelAgg)->getSomething( rId );
3175 return theScModelObjUnoTunnelId.
getSeq();
3206 bool bInvalidateDataArea,
bool bExtendDataArea)
3208 size_t nRangeCount = rRanges.
size();
3210 for (
size_t nIndex = 0;
nIndex < nRangeCount; ++
nIndex )
3216 bool bAreaExtended =
false;
3218 if (bExtendDataArea)
3225 bAreaExtended = rEnd.
Col() > nLastCol || rEnd.
Row() > nLastRow;
3228 bool bInvalidate = bAreaExtended || bInvalidateDataArea;
3244 const uno::Sequence< beans::PropertyValue >& rProperties )
3246 OUString aOperation = rOperation;
3247 bool bIsDataAreaInvalidateType = aOperation ==
"data-area-invalidate";
3248 bool bIsDataAreaExtendType = aOperation ==
"data-area-extend";
3250 bool bInvalidateDataArea = bIsDataAreaInvalidateType
3252 bool bExtendDataArea = bIsDataAreaExtendType || aOperation ==
"cell-change";
3257 lcl_dataAreaInvalidation(rDocument,
this, rRanges, bInvalidateDataArea, bExtendDataArea);
3260 if (bIsDataAreaInvalidateType || bIsDataAreaExtendType)
3265 if (rOperation ==
"delete-content" || rOperation ==
"undo"
3266 || rOperation ==
"redo" || rOperation ==
"paste")
3267 aOperation =
"cell-change";
3272 util::ChangesEvent
aEvent;
3276 size_t nRangeCount = rRanges.
size();
3277 aEvent.Changes.realloc(
static_cast< sal_Int32
>( nRangeCount ) );
3278 auto pChanges =
aEvent.Changes.getArray();
3281 uno::Reference< table::XCellRange > xRangeObj;
3293 util::ElementChange& rChange = pChanges[
static_cast< sal_Int32
>(
nIndex ) ];
3294 rChange.Accessor <<= aOperation;
3295 rChange.Element <<= rProperties;
3296 rChange.ReplacedElement <<= xRangeObj;
3306 catch( uno::Exception& )
3314 if ( !(aOperation ==
"cell-change" &&
pDocShell) )
3321 for (
const SCTAB& nTab : aMarkData)
3323 if (nTab >= nTabCount)
3332 size_t nRangeCount = rRanges.
size();
3339 size_t nTabRangeCount = aTabRanges.
size();
3340 if ( nTabRangeCount > 0 )
3342 uno::Reference<uno::XInterface>
xTarget;
3343 if ( nTabRangeCount == 1 )
3345 ScRange const & rRange = aTabRanges[ 0 ];
3357 uno::Sequence<sal_Int16> aOutArgsIndex;
3358 uno::Sequence<uno::Any> aOutArgs;
3378 for (
SCTAB nTab = 0; nTab < nTabCount; nTab++)
3387 uno::Sequence<uno::Any> aParams;
3388 uno::Sequence<sal_Int16> aOutArgsIndex;
3389 uno::Sequence<uno::Any> aOutArgs;
3396 uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( rDoc.
GetVbaEventProcessor(), uno::UNO_SET_THROW );
3397 uno::Sequence< uno::Any > aArgs{
uno::Any(nTab) };
3400 catch( uno::Exception& )
3424 officecfg::Office::Common::Misc::UseOpenCL::set(bEnable, batch);
3432#if HAVE_FEATURE_OPENCL
3433 sc::FormulaGroupInterpreter::switchOpenCLDevice(
u"",
true);
3448 SC_MOD()->SetFormulaOptions(aOptions);
3449#if !HAVE_FEATURE_OPENCL
3452 sc::FormulaGroupInterpreter::switchOpenCLDevice(
u"",
true, bForce);
3463 SC_MOD()->SetFormulaOptions(aOptions);
3468 if(nPlatform < 0 || nDevice < 0)
3469 throw uno::RuntimeException();
3471#if !HAVE_FEATURE_OPENCL
3472 throw uno::RuntimeException();
3474 std::vector<OpenCLPlatformInfo> aPlatformInfo;
3475 sc::FormulaGroupInterpreter::fillOpenCLInfo(aPlatformInfo);
3477 throw uno::RuntimeException();
3480 throw uno::RuntimeException();
3482 OUString aDeviceString = aPlatformInfo[nPlatform].maVendor +
" " + aPlatformInfo[nPlatform].maDevices[nDevice].maName;
3483 sc::FormulaGroupInterpreter::switchOpenCLDevice(aDeviceString,
false);
3489#if !HAVE_FEATURE_OPENCL
3492 sal_Int32 nPlatformId;
3493 sal_Int32 nDeviceId;
3494 sc::FormulaGroupInterpreter::getOpenCLDeviceInfo(nDeviceId, nPlatformId);
3501#if !HAVE_FEATURE_OPENCL
3504 sal_Int32 nPlatformId;
3505 sal_Int32 nDeviceId;
3506 sc::FormulaGroupInterpreter::getOpenCLDeviceInfo(nDeviceId, nPlatformId);
3513#if !HAVE_FEATURE_OPENCL
3514 return uno::Sequence<sheet::opencl::OpenCLPlatform>();
3516 std::vector<OpenCLPlatformInfo> aPlatformInfo;
3517 sc::FormulaGroupInterpreter::fillOpenCLInfo(aPlatformInfo);
3519 uno::Sequence<sheet::opencl::OpenCLPlatform> aRet(aPlatformInfo.size());
3520 auto aRetRange = asNonConstRange(aRet);
3521 for(
size_t i = 0;
i < aPlatformInfo.size(); ++
i)
3523 aRetRange[
i].Name = aPlatformInfo[
i].maName;
3524 aRetRange[
i].Vendor = aPlatformInfo[
i].maVendor;
3526 aRetRange[
i].Devices.realloc(aPlatformInfo[
i].maDevices.size());
3527 auto pDevices = aRetRange[
i].Devices.getArray();
3528 for(
size_t j = 0; j < aPlatformInfo[
i].maDevices.size(); ++j)
3531 pDevices[j].Name = rDevice.
maName;
3532 pDevices[j].Vendor = rDevice.
maVendor;
3533 pDevices[j].Driver = rDevice.
maDriver;
3544void setOpcodeSubsetTest(
bool bFlag)
3547 officecfg::Office::Calc::Formula::Calculation::OpenCLSubsetOnly::set(bFlag, batch);
3555 setOpcodeSubsetTest(
true);
3560 setOpcodeSubsetTest(
false);
3565 return officecfg::Office::Calc::Formula::Calculation::OpenCLSubsetOnly::get();
3571 officecfg::Office::Calc::Formula::Calculation::OpenCLMinimumDataSize::set(number, batch);
3577 return officecfg::Office::Calc::Formula::Calculation::OpenCLMinimumDataSize::get();
3598 if ( rHint.
GetId() == SfxHintId::Dying )
3609 OSL_ENSURE(pDrawLayer,
"Cannot create Draw-Layer");
3610 if ( pDrawLayer &&
nIndex >= 0 && nIndex < pDocShell->GetDocument().GetTableCount() )
3613 OSL_ENSURE(pPage,
"Draw-Page not found");
3616 return uno::Reference<drawing::XDrawPage> (pPage->
getUnoPage(), uno::UNO_QUERY);
3628 uno::Reference<drawing::XDrawPage> xRet;
3634 aNewName,
true,
true ) )
3643 SvxDrawPage* pImp = comphelper::getFromUnoTunnel<SvxDrawPage>( xPage );
3670 throw lang::IndexOutOfBoundsException();
3704 if ( rHint.
GetId() == SfxHintId::Dying )
3714 if (
pDocShell &&
nIndex >= 0 && nIndex < pDocShell->GetDocument().GetTableCount() )
3740 throw uno::RuntimeException();
3754 throw uno::RuntimeException();
3758 const OUString& aCopy, sal_Int16 nDestination )
3771 SCTAB nResultTab =
static_cast<SCTAB>(nDestination);
3773 if (nResultTab >= nTabCount)
3774 nResultTab = nTabCount - 1;
3782 throw uno::RuntimeException();
3789 bool bIllArg =
false;
3795 uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY);
3796 if ( xInterface.is() )
3799 if ( pSheetObj && !pSheetObj->GetDocShell() )
3806 throw container::ElementExistException();
3825 throw lang::IllegalArgumentException();
3827 throw uno::RuntimeException();
3835 bool bIllArg =
false;
3841 uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY);
3842 if ( xInterface.is() )
3845 if ( pSheetObj && !pSheetObj->GetDocShell() )
3851 throw container::NoSuchElementException();
3873 throw lang::IllegalArgumentException();
3875 throw uno::RuntimeException();
3887 throw container::NoSuchElementException();
3892 throw uno::RuntimeException();
3896 const uno::Reference < sheet::XSpreadsheetDocument > & xDocSrc,
3897 const OUString& srcName,
const sal_Int32 nDestPosition )
3903 if ( !xDocSrc.is() )
3904 throw uno::RuntimeException();
3905 ScModelObj* pObj = comphelper::getFromUnoTunnel<ScModelObj>(xDocSrc);
3911 throw lang::IllegalArgumentException();
3915 SCTAB nIndexDest =
static_cast<SCTAB>(nDestPosition);
3916 if (nIndexDest >
nCount || nIndexDest < 0)
3917 throw lang::IndexOutOfBoundsException();
3921 *pDocShellSrc, nIndexSrc, nIndexDest,
true,
true );
3933 throw lang::IndexOutOfBoundsException();
3935 return xSheet->getCellByPosition(nColumn, nRow);
3943 throw lang::IndexOutOfBoundsException();
3945 return xSheet->getCellRangeByPosition(nLeft, nTop, nRight, nBottom);
3951 uno::Sequence < uno::Reference < table::XCellRange > > xRet;
3956 throw lang::IllegalArgumentException();
3960 throw lang::IllegalArgumentException();
3963 auto pRet = xRet.getArray();
3996 throw lang::IndexOutOfBoundsException();
4021 throw container::NoSuchElementException();
4035 OUString* pAry =
aSeq.getArray();
4043 return uno::Sequence<OUString>();
4059 pDocShell( pDocSh ),
4081 else if ( rHint.
GetId() == SfxHintId::Dying )
4124 throw uno::RuntimeException();
4143 throw uno::RuntimeException();
4167 throw lang::IndexOutOfBoundsException();
4189 throw container::NoSuchElementException();
4199 OUString* pAry =
aSeq.getArray();
4221 static uno::Reference<beans::XPropertySetInfo> aRef(
4227 const OUString& aPropertyName,
const uno::Any& aValue )
4231 throw uno::RuntimeException();
4238 sal_Int32 nNewWidth = 0;
4239 if ( aValue >>= nNewWidth )
4274 throw uno::RuntimeException();
4314 pDocShell( pDocSh ),
4319 pDocShell->GetDocument().AddUnoObject(*
this);
4336 else if ( rHint.
GetId() == SfxHintId::Dying )
4369 throw uno::RuntimeException();
4385 throw uno::RuntimeException();
4409 throw lang::IndexOutOfBoundsException();
4429 static uno::Reference<beans::XPropertySetInfo> aRef(
4435 const OUString& aPropertyName,
const uno::Any& aValue )
4439 throw uno::RuntimeException();
4447 sal_Int32 nNewHeight = 0;
4469 sal_Int32 nNewHeight = 0;
4470 if ( aValue >>= nNewHeight )
4526 xRangeObj->setPropertyValue( aPropertyName, aValue );
4534 throw uno::RuntimeException();
4580 aAny = xRangeObj->getPropertyValue( aPropertyName );
4600 const OUString& ,
const uno::Any& )
4612 pDocShell( pDocSh ),
4615 pDocShell->GetDocument().AddUnoObject(*
this);
4630 if ( rHint.
GetId() == SfxHintId::Dying )
4660 const table::CellAddress& aPosition,
const OUString& rText )
4665 OSL_ENSURE( aPosition.Sheet ==
nTab,
"addAnnotation with a wrong Sheet" );
4695 return new ScIndexEnumeration(
this,
"com.sun.star.sheet.CellAnnotationsEnumeration");
4717 if (!xAnnotation.is())
4718 throw lang::IndexOutOfBoundsException();
4735 pDocShell( pDocSh ),
4755 else if ( rHint.
GetId() == SfxHintId::Dying )
4774 if (aTabName == rName)
4803 const uno::Sequence<table::CellRangeAddress>& aRanges,
4804 const OUString& aComment )
4813 for (
const table::CellRangeAddress& rRange : aRanges)
4815 OSL_ENSURE( rRange.Sheet ==
nTab,
"addScenario with a wrong Tab" );
4817 static_cast<SCCOL>(rRange.EndColumn),
static_cast<SCROW>(rRange.EndRow),
nTab );
4857 while (nNext < nTabCount && rDoc.
IsScenario(nNext))
4872 throw lang::IndexOutOfBoundsException();
4893 throw container::NoSuchElementException();
4908 OUString* pAry =
aSeq.getArray();
constexpr auto convertTwipToMm100(N n)
constexpr OUStringLiteral SC_POSITIONLEFT
constexpr OUStringLiteral SC_ACTIVETABLE
constexpr OUStringLiteral SC_POSITIONTOP
void ScColToAlpha(OUStringBuffer &rBuf, SCCOL nCol)
append alpha representation of column to buffer
bool AlphaToCol(const ScDocument &rDoc, SCCOL &rCol, std::u16string_view rStr)
get column number of A..IV... string
bool ValidTab(SCTAB nTab)
static bool LOKHandleMouseEvent(VclEventId nEvent, vcl::Window *pWin, const MouseEvent *pEvent)
static const AllSettings & GetSettings()
OUString AsRGBHexString() const
static bool HasValidData(const css::uno::Reference< css::datatransfer::XTransferable > &rTransferable)
css::uno::Reference< css::datatransfer::XTransferable > GetTransferable() const
void SetCursorLogicPosition(const Point &rPosition, bool bPoint, bool bClearMark)
const tools::Rectangle & GetOutputArea() const
bool setGraphicSelection(int nType, int nX, int nY, double fScaleX=1.0, double fScaleY=1.0)
bool setTextSelection(int nType, int nX, int nY)
static bool postMouseEvent(const SdrPage *pPage, const SdrView *pDrawView, vcl::Window const &rMainWindow, int nType, Point aPointHmm, int nCount, int nButtons, int nModifier)
static void paintControlTile(const SdrPage *pPage, const SdrView *pDrawView, vcl::Window const &rMainWindow, VirtualDevice &rDevice, Size aOutputSize, tools::Rectangle const &rTileRect)
bool Select(sal_Int32 nIndex, bool bSelect=true)
void SetTotalRange(const Range &rTotRange)
EditView & GetEditView() const
Size GetOutputSize() const
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
vcl::ExtOutDevData * GetExtOutDevData() const
void SetDigitLanguage(LanguageType)
SC_DLLPUBLIC ScRefFlags Parse(const OUString &, const ScDocument &, const Details &rDetails=detailsOOOa1, ExternalInfo *pExtInfo=nullptr, const css::uno::Sequence< css::sheet::ExternalLinkInfo > *pExternalLinks=nullptr, sal_Int32 *pSheetEndPos=nullptr, const OUString *pErrRef=nullptr)
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
SCTAB nTab
Collection belongs to the sheet.
virtual ~ScAnnotationsObj() override
virtual css::uno::Type SAL_CALL getElementType() override
XElementAccess.