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());
1244 OStringBuffer aState;
1253 aState.append(aThemeName);
1256 return aState.makeStringAndClear();
1266 SC_MOD()->SetAppOptions(aAppOptions);
1268 for (
const beans::PropertyValue& rValue : rArguments)
1270 if (rValue.Name ==
".uno:SpellOnline" && rValue.Value.has<
bool>())
1282 SC_MOD()->SetInputOptions(aInputOptions);
1290 officecfg::Office::Common::Save::Document::WarnAlienFormat::set(
false, xChanges);
1325 aRet =
xNumberAgg->queryAggregation( rType );
1343 static const uno::Sequence<uno::Type>
aTypes = [&]()
1345 uno::Sequence<uno::Type> aAggTypes;
1353 aAggTypes = (*xNumProv)->getTypes();
1359 uno::Sequence<uno::Type>
1384 return css::uno::Sequence<sal_Int8>();
1392 if (
nId == SfxHintId::Dying )
1398 comphelper::getFromUnoTunnel<SvNumberFormatsSupplierObj>(
1399 uno::Reference<util::XNumberFormatsSupplier>(
xNumberAgg, uno::UNO_QUERY) );
1407 else if (
nId == SfxHintId::DataChanged )
1451 return css::uno::Reference< ::css::chart2::data::XDataProvider > (
1472 for (
const beans::PropertyValue& rProp : rOptions)
1474 const OUString & rPropName = rProp.Name;
1478 uno::Reference<awt::XDevice> xRenderDevice(rProp.Value, uno::UNO_QUERY);
1479 if ( xRenderDevice.is() )
1500 sal_Int32 nNumeric = 0;
1502 bool bRangeValid =
false;
1503 bool bRectValid =
false;
1511 rTargetRange = aAddress;
1520 ( nNumeric =
rTarget.toInt32() ) > 0 && nNumeric <= rDoc.
MaxRow()+1 )
1523 rTargetRange =
ScAddress( 0,
static_cast<SCROW>(nNumeric-1), nSourceTab );
1540 for (
SCTAB i=0;
i<nTabCount && !bRangeValid;
i++)
1543 OSL_ENSURE(pPage,
"Page ?");
1548 while (
pObject && !bRangeValid)
1552 rTargetRect =
pObject->GetLogicRect();
1553 rTargetRange = rDoc.
GetRange(
i, rTargetRect );
1554 bRangeValid = bRectValid =
true;
1562 if ( bRangeValid && !bRectValid )
1574 const uno::Sequence< beans::PropertyValue >& rOptions,
1577 bool& rbRenderToGraphic )
const
1579 OSL_ENSURE( !rMark.
IsMarked() && !rMark.
IsMultiMarked(),
"FillRenderMarkData: MarkData must be empty" );
1580 OSL_ENSURE(
pDocShell,
"FillRenderMarkData: DocShell must be set" );
1584 uno::Reference<frame::XController> xView;
1587 bool bSelectedSheetsOnly =
false;
1588 bool bSuppressEmptyPages =
true;
1590 bool bHasPrintContent =
false;
1591 sal_Int32 nPrintContent = 0;
1592 sal_Int32 nPrintRange = 0;
1593 sal_Int32 nEOContent = 0;
1594 OUString aPageRange;
1596 for(
const auto& rOption : rOptions )
1598 if ( rOption.Name ==
"IsOnlySelectedSheets" )
1600 rOption.Value >>= bSelectedSheetsOnly;
1602 else if ( rOption.Name ==
"IsSuppressEmptyPages" )
1604 rOption.Value >>= bSuppressEmptyPages;
1606 else if ( rOption.Name ==
"PageRange" )
1608 rOption.Value >>= aPageRange;
1610 else if ( rOption.Name ==
"PrintRange" )
1612 rOption.Value >>= nPrintRange;
1614 else if ( rOption.Name ==
"EvenOdd" )
1616 rOption.Value >>= nEOContent;
1618 else if ( rOption.Name ==
"PrintContent" )
1620 bHasPrintContent =
true;
1621 rOption.Value >>= nPrintContent;
1623 else if ( rOption.Name ==
"View" )
1625 rOption.Value >>= xView;
1627 else if ( rOption.Name ==
"RenderToGraphic" )
1629 rOption.Value >>= rbRenderToGraphic;
1634 if ( bHasPrintContent )
1635 bSelectedSheetsOnly = ( nPrintContent != 0 );
1637 uno::Reference<uno::XInterface> xInterface(aSelection, uno::UNO_QUERY);
1638 if ( xInterface.is() )
1640 ScCellRangesBase* pSelObj =
dynamic_cast<ScCellRangesBase*
>( xInterface.get() );
1641 uno::Reference< drawing::XShapes > xShapes( xInterface, uno::UNO_QUERY );
1642 if ( pSelObj && pSelObj->GetDocShell() ==
pDocShell )
1644 bool bSheet = (
dynamic_cast<ScTableSheetObj*
>( pSelObj ) !=
nullptr );
1645 bool bCursor = pSelObj->IsCursorOnly();
1646 const ScRangeList& rRanges = pSelObj->GetRangeList();
1664 if ( bCursor || bSheet )
1677 else if( xShapes.is() )
1681 uno::Reference< drawing::XShape > xShape( xShapes->getByIndex(0), uno::UNO_QUERY );
1698 else if ( comphelper::getFromUnoTunnel<ScModelObj>( xInterface ) ==
this )
1704 for (
SCTAB nTab = 0; nTab < nTabCount; nTab++)
1713 uno::Reference<sheet::XSelectedSheetsSupplier> xSelectedSheets(xView, uno::UNO_QUERY);
1714 if (bSelectedSheetsOnly &&
pDocShell && xSelectedSheets.is())
1716 const uno::Sequence<sal_Int32> aSelected = xSelectedSheets->getSelectedSheets();
1719 for (
const auto& rSelected : aSelected)
1721 SCTAB nSelected =
static_cast<SCTAB>(rSelected);
1723 aSelectedTabs.insert(nSelected);
1734 if ( nPrintRange == 1 )
1735 rPagesStr = aPageRange;
1743 const uno::Sequence<beans::PropertyValue>& rOptions)
1748 throw lang::DisposedException( OUString(),
1749 static_cast< sheet::XSpreadsheetDocument*
>(
this) );
1755 bool bRenderToGraphic =
false;
1756 if ( !
FillRenderMarkData( aSelection, rOptions, aMark, aStatus, aPagesStr, bRenderToGraphic ) )
1772 sal_Int32 nContent = 0;
1773 sal_Int32 nEOContent = 0;
1774 bool bSinglePageSheets =
false;
1775 for (
const auto& rValue : rOptions)
1777 if ( rValue.Name ==
"PrintRange" )
1779 rValue.Value >>= nContent;
1781 else if ( rValue.Name ==
"SinglePageSheets" )
1783 rValue.Value >>= bSinglePageSheets;
1785 else if ( rValue.Name ==
"EvenOdd" )
1787 rValue.Value >>= nEOContent;
1791 if (bSinglePageSheets)
1796 bool bIsPrintEvenPages = (nEOContent != 1 && nContent == 0) || nContent != 0;
1797 bool bIsPrintOddPages = (nEOContent != 2 && nContent == 0) || nContent != 0;
1799 for ( sal_Int32 nPage = 1; nPage <= nPages; nPage++ )
1805 sal_Int32 nSelectCount =
static_cast<sal_Int32
>(
maValidPages.size() );
1807 if ( nEOContent == 1 || nEOContent == 2 )
1808 return nSelectCount;
1810 if ( !aPagesStr.isEmpty() )
1813 nSelectCount = aRangeEnum.
size();
1815 return (nSelectCount > 0) ? nSelectCount : 1;
1818static sal_Int32
lcl_GetRendererNum( sal_Int32 nSelRenderer, std::u16string_view rPagesStr, sal_Int32 nTotalPages )
1820 if ( rPagesStr.empty() )
1821 return nSelRenderer;
1826 for ( ; nSelRenderer > 0 && aIter != aEnd; --nSelRenderer )
1838 const uno::Any& aSelection,
const uno::Sequence<beans::PropertyValue>& rOptions )
1843 throw lang::DisposedException( OUString(),
1844 static_cast< sheet::XSpreadsheetDocument*
>(
this) );
1852 bool bRenderToGraphic =
false;
1853 bool bSinglePageSheets =
false;
1854 if (
FillRenderMarkData( aSelection, rOptions, aMark, aStatus, aPagesStr, bRenderToGraphic ) )
1863 for (
const auto& rValue : rOptions)
1865 if ( rValue.Name ==
"SinglePageSheets" )
1867 rValue.Value >>= bSinglePageSheets;
1872 if (bSinglePageSheets)
1877 if ( nRenderer < 0 )
1879 if ( nSelRenderer != 0 )
1880 throw lang::IllegalArgumentException();
1884 awt::Size aPageSize;
1892 aPageSize.Width = aMMRect.
GetWidth();
1897 SCTAB const nCurTab = 0;
1920 if (bSinglePageSheets)
1921 nTab = nSelRenderer;
1929 const ScRange* pSelRange =
nullptr;
1930 if ( bSinglePageSheets )
1943 table::CellRangeAddress aRangeAddress( nTab,
1951 const awt::Point aCalcPagePos(aMMRect.
Left(), aMMRect.
Top());
1953 uno::Sequence<beans::PropertyValue> aSequence
1973 pSelRange = &aRange;
1976 awt::Size aPageSize;
1977 bool bWasCellRange =
false;
1981 bWasCellRange =
true;
1982 aCellRange = aRange;
1986 aPageSize.Width = aMMRect.
GetWidth();
1991 std::unique_ptr<ScPrintFunc, o3tl::default_delete<ScPrintFunc>> pPrintFunc;
1997 pPrintFunc->SetRenderFlag(
true );
1999 sal_Int32 nContent = 0;
2000 sal_Int32 nEOContent = 0;
2001 for (
const auto& rValue : rOptions)
2003 if ( rValue.Name ==
"PrintRange" )
2005 rValue.Value >>= nContent;
2007 else if ( rValue.Name ==
"EvenOdd" )
2009 rValue.Value >>= nEOContent;
2016 bool bOddOrEven = (nContent == 0 && nEOContent == 1) || (nContent == 1 && nEOContent == 2);
2023 aPage.
Select( nRenderer+1 );
2028 (void)pPrintFunc->DoPrint( aPage, nTabStart, nDisplayStart,
false,
nullptr );
2030 bWasCellRange = pPrintFunc->GetLastSourceRange( aCellRange );
2031 Size aTwips = pPrintFunc->GetPageSize();
2044 uno::Sequence<beans::PropertyValue> aSequence(nPropCount);
2045 beans::PropertyValue* pArray = aSequence.getArray();
2047 pArray[0].Value <<= aPageSize;
2050 pArray[1].Value <<=
true;
2051 if ( bWasCellRange )
2053 table::CellRangeAddress aRangeAddress( nTab,
2061 const awt::Point aCalcPagePos(aMMRect.
Left(), aMMRect.
Top());
2064 pArray[2].Value <<= aRangeAddress;
2066 pArray[3].Value <<= aCalcPageSize;
2068 pArray[4].Value <<= aCalcPagePos;
2080 const uno::Sequence<beans::PropertyValue>& rOptions )
2085 throw lang::DisposedException( OUString(),
2086 static_cast< sheet::XSpreadsheetDocument*
>(
this) );
2092 bool bRenderToGraphic =
false;
2093 bool bSinglePageSheets =
false;
2094 if ( !
FillRenderMarkData( aSelection, rOptions, aMark, aStatus, aPagesStr, bRenderToGraphic ) )
2095 throw lang::IllegalArgumentException();
2103 for (
const auto& rValue : rOptions)
2105 if ( rValue.Name ==
"SinglePageSheets" )
2107 rValue.Value >>= bSinglePageSheets;
2112 if (bSinglePageSheets)
2116 if ( nRenderer < 0 )
2117 throw lang::IllegalArgumentException();
2121 throw lang::IllegalArgumentException();
2126 const ScRange* pSelRange =
nullptr;
2127 if ( bSinglePageSheets )
2129 awt::Size aPageSize;
2132 rDoc.
GetDataStart( nSelRenderer, nStartCol, nStartRow );
2144 aPageSize.Width = aMMRect.
GetWidth();
2149 if (nVisTab != nSelRenderer)
2151 nVisTab = nSelRenderer;
2162 pSelRange = &aRange;
2176 const double nPrintFactor = 1.0;
2185 struct DrawViewKeeper
2187 std::unique_ptr<FmFormView> mpDrawView;
2193 mpDrawView->HideSdrPage();
2209 aDrawViewKeeper.mpDrawView.reset(
new FmFormView(
2212 aDrawViewKeeper.mpDrawView->ShowSdrPage(aDrawViewKeeper.mpDrawView->GetModel().GetPage(nTab));
2213 aDrawViewKeeper.mpDrawView->SetPrintPreview();
2220 std::unique_ptr<ScPrintFunc, o3tl::default_delete<ScPrintFunc>> pPrintFunc;
2227 pPrintFunc->SetDrawView( aDrawViewKeeper.mpDrawView.get() );
2228 pPrintFunc->SetRenderFlag(
true );
2230 pPrintFunc->SetExclusivelyDrawOleAndDrawObjects();
2232 sal_Int32 nContent = 0;
2233 sal_Int32 nEOContent = 0;
2234 for (
const auto& rValue : rOptions)
2236 if ( rValue.Name ==
"PrintRange" )
2238 rValue.Value >>= nContent;
2240 else if ( rValue.Name ==
"EvenOdd" )
2242 rValue.Value >>= nEOContent;
2249 bool bOddOrEven = (nContent == 0 && nEOContent == 1) || (nContent == 0 && nEOContent == 2);
2256 aPage.
Select( nRenderer+1 );
2262 if ( nRenderer == nTabStart )
2276 sal_Int32 nDestID = pPDFData->
CreateDest( aArea );
2278 rDoc.
GetName( nTab, aTabName );
2287 rDoc.
GetName( nTab, aTabName );
2293 (void)pPrintFunc->DoPrint( aPage, nTabStart, nDisplayStart,
true,
nullptr );
2308 std::vector< vcl::PDFExtOutDevBookmarkEntry >& rBookmarks = pPDFData->
GetBookmarks();
2309 for (
const auto& rBookmark : rBookmarks )
2311 OUString aBookmark = rBookmark.aBookmark;
2312 if ( aBookmark.toChar() ==
'#' )
2316 OUString aTarget( aBookmark.copy( 1 ) );
2320 bool bIsSheet =
false;
2321 bool bValid =
lcl_ParseTarget( aTarget, aTargetRange, aTargetRect, bIsSheet, rDoc, nTab );
2325 sal_Int32 nPage = -1;
2341 nPage = aLocation.
nPage;
2363 if ( nX1 > aLocationPixel.
Right() ) nX1 = aLocationPixel.
Right();
2364 if ( nX2 > aLocationPixel.
Right() ) nX2 = aLocationPixel.
Right();
2365 if ( nY1 > aLocationPixel.
Bottom() ) nY1 = aLocationPixel.
Bottom();
2366 if ( nY2 > aLocationPixel.
Bottom() ) nY2 = aLocationPixel.
Bottom();
2382 pPDFData->
SetLinkURL( rBookmark.nLinkId, aBookmark );
2403 bool bLocked =
false;
2433 sal_uInt16 nRet = 0;
2473 OSL_FAIL(
"no DocShell");
2487 OSL_FAIL(
"no DocShell");
2497 OSL_FAIL(
"no DocShell");
2503 bool bEnabled(bEnabledIn);
2516 OSL_FAIL(
"no DocShell");
2539 throw lang::IllegalArgumentException();
2549 OSL_FAIL(
"no DocShell");
2561 OSL_FAIL(
"no DocShell");
2568 const table::CellAddress& aFormulaPosition,
2569 const table::CellAddress& aVariablePosition,
2570 const OUString& aGoalValue )
2573 sheet::GoalResult aResult;
2574 aResult.Divergence = DBL_MAX;
2579 double fValue = 0.0;
2580 bool bFound = rDoc.
Solver(
2581 static_cast<SCCOL>(aFormulaPosition.Column),
static_cast<SCROW>(aFormulaPosition.Row), aFormulaPosition.Sheet,
2582 static_cast<SCCOL>(aVariablePosition.Column),
static_cast<SCROW>(aVariablePosition.Row), aVariablePosition.Sheet,
2583 aGoalValue, fValue );
2584 aResult.Result = fValue;
2586 aResult.Divergence = 0.0;
2603 pNew->SetParam( *pParam );
2609 const uno::Reference<sheet::XConsolidationDescriptor>& xDescriptor )
2618 xImpl->setFunction( xDescriptor->getFunction() );
2619 xImpl->setSources( xDescriptor->getSources() );
2620 xImpl->setStartOutputPosition( xDescriptor->getStartOutputPosition() );
2621 xImpl->setUseColumnHeaders( xDescriptor->getUseColumnHeaders() );
2622 xImpl->setUseRowHeaders( xDescriptor->getUseRowHeaders() );
2623 xImpl->setInsertLinks( xDescriptor->getInsertLinks() );
2659 uno::Sequence< beans::PropertyValue >
aSeq{
2677 static uno::Reference<beans::XPropertySetInfo> aRef(
2683 const OUString& aPropertyName,
const uno::Any& aValue )
2705 bHardRecalc =
false;
2709 lang::Locale aLocale;
2710 if ( aValue >>= aLocale )
2721 if ( aValue >>= sCodeName )
2726 lang::Locale aLocale;
2727 if ( aValue >>= aLocale )
2737 lang::Locale aLocale;
2738 if ( aValue >>= aLocale )
2754 pBindings->
Invalidate( SID_FM_OPEN_READONLY );
2764 pBindings->
Invalidate( SID_FM_AUTOCONTROLFOCUS );
2776 ? officecfg::Office::Common::Undo::Steps::get() : 0);
2782 bool bChangeAllowed =
true;
2783 if (!bRecordChangesEnabled)
2804 else if ( aPropertyName ==
"BuildId" )
2808 else if ( aPropertyName ==
"SavedObject" )
2811 aValue >>= aObjName;
2812 if ( !aObjName.isEmpty() )
2820 if ( aNewOpt != rOldOpt )
2849 lang::Locale aLocale;
2863 lang::Locale aLocale;
2872 lang::Locale aLocale;
2917 aRet <<= bOpenInDesign;
2924 aRet <<= bAutoControlFocus;
2949 aRet <<= OUString(
"ThisExcelDoc" );
2991 aRet <<= uno::Reference< awt::XDevice >( pXDev );
2993 else if ( aPropertyName ==
"BuildId" )
2997 else if ( aPropertyName ==
"InternalDocument" )
3015 OUString const & aServiceSpecifier,
3016 css::
uno::Sequence<css::
uno::Any> const * arguments)
3020 uno::Reference<uno::XInterface> xRet;
3022 if (
nType != ServiceType::INVALID )
3028 case ServiceType::GRADTAB: xRet.set(xDrawGradTab);
break;
3029 case ServiceType::HATCHTAB: xRet.set(xDrawHatchTab);
break;
3030 case ServiceType::BITMAPTAB: xRet.set(xDrawBitmapTab);
break;
3031 case ServiceType::TRGRADTAB: xRet.set(xDrawTrGradTab);
break;
3032 case ServiceType::MARKERTAB: xRet.set(xDrawMarkerTab);
break;
3033 case ServiceType::DASHTAB: xRet.set(xDrawDashTab);
break;
3034 case ServiceType::CHDATAPROV: xRet.set(xChartDataProv);
break;
3035 case ServiceType::VBAOBJECTPROVIDER: xRet.set(xObjProvider);
break;
3042 (
nType != ServiceType::CHDATAPROV ||
3043 ( pDocShell->GetCreateMode() != SfxObjectCreateMode::INTERNAL ));
3048 if ( !xRet.is() && bCreate )
3055 case ServiceType::GRADTAB: xDrawGradTab.set(xRet);
break;
3056 case ServiceType::HATCHTAB: xDrawHatchTab.set(xRet);
break;
3057 case ServiceType::BITMAPTAB: xDrawBitmapTab.set(xRet);
break;
3058 case ServiceType::TRGRADTAB: xDrawTrGradTab.set(xRet);
break;
3059 case ServiceType::MARKERTAB: xDrawMarkerTab.set(xRet);
break;
3060 case ServiceType::DASHTAB: xDrawDashTab.set(xRet);
break;
3061 case ServiceType::CHDATAPROV: xChartDataProv.set(xRet);
break;
3062 case ServiceType::VBAOBJECTPROVIDER: xObjProvider.set(xRet);
break;
3074 xRet = arguments ==
nullptr
3077 aServiceSpecifier, *arguments);
3080 catch ( lang::ServiceNotRegisteredException & )
3087 uno::Reference<drawing::XShape> xShape( xRet, uno::UNO_QUERY );
3099 const OUString& aServiceSpecifier )
3102 return create(aServiceSpecifier,
nullptr);
3106 const OUString& ServiceSpecifier,
3107 const uno::Sequence<uno::Any>& aArgs )
3112 uno::Reference<uno::XInterface> xInt(
create(ServiceSpecifier, &aArgs));
3114 if ( aArgs.hasElements() )
3118 uno::Reference<lang::XInitialization> xInit( xInt, uno::UNO_QUERY );
3120 xInit->initialize( aArgs );
3137 return "ScModelObj";
3156 const uno::Sequence<sal_Int8 >& rId )
3158 if ( comphelper::isUnoTunnelId<ScModelObj>(rId) )
3163 if ( comphelper::isUnoTunnelId<SfxObjectShell>(rId) )
3179 if(
auto xTunnelAgg =
o3tl::tryAccess<uno::Reference<lang::XUnoTunnel>>(
3182 return (*xTunnelAgg)->getSomething( rId );
3192 return theScModelObjUnoTunnelId.
getSeq();
3223 bool bInvalidateDataArea,
bool bExtendDataArea)
3225 size_t nRangeCount = rRanges.
size();
3227 for (
size_t nIndex = 0;
nIndex < nRangeCount; ++
nIndex )
3233 bool bAreaExtended =
false;
3235 if (bExtendDataArea)
3242 bAreaExtended = rEnd.
Col() > nLastCol || rEnd.
Row() > nLastRow;
3245 bool bInvalidate = bAreaExtended || bInvalidateDataArea;
3261 const uno::Sequence< beans::PropertyValue >& rProperties )
3263 OUString aOperation = rOperation;
3264 bool bIsDataAreaInvalidateType = aOperation ==
"data-area-invalidate";
3265 bool bIsDataAreaExtendType = aOperation ==
"data-area-extend";
3267 bool bInvalidateDataArea = bIsDataAreaInvalidateType
3269 bool bExtendDataArea = bIsDataAreaExtendType || aOperation ==
"cell-change";
3274 lcl_dataAreaInvalidation(rDocument,
this, rRanges, bInvalidateDataArea, bExtendDataArea);
3277 if (bIsDataAreaInvalidateType || bIsDataAreaExtendType)
3282 if (rOperation ==
"delete-content" || rOperation ==
"undo"
3283 || rOperation ==
"redo" || rOperation ==
"paste")
3284 aOperation =
"cell-change";
3289 util::ChangesEvent
aEvent;
3293 size_t nRangeCount = rRanges.
size();
3294 aEvent.Changes.realloc(
static_cast< sal_Int32
>( nRangeCount ) );
3295 auto pChanges =
aEvent.Changes.getArray();
3298 uno::Reference< table::XCellRange > xRangeObj;
3310 util::ElementChange& rChange = pChanges[
static_cast< sal_Int32
>(
nIndex ) ];
3311 rChange.Accessor <<= aOperation;
3312 rChange.Element <<= rProperties;
3313 rChange.ReplacedElement <<= xRangeObj;
3323 catch( uno::Exception& )
3331 if ( !(aOperation ==
"cell-change" &&
pDocShell) )
3338 for (
const SCTAB& nTab : aMarkData)
3340 if (nTab >= nTabCount)
3349 size_t nRangeCount = rRanges.
size();
3356 size_t nTabRangeCount = aTabRanges.
size();
3357 if ( nTabRangeCount > 0 )
3359 uno::Reference<uno::XInterface>
xTarget;
3360 if ( nTabRangeCount == 1 )
3362 ScRange const & rRange = aTabRanges[ 0 ];
3374 uno::Sequence<sal_Int16> aOutArgsIndex;
3375 uno::Sequence<uno::Any> aOutArgs;
3395 for (
SCTAB nTab = 0; nTab < nTabCount; nTab++)
3404 uno::Sequence<uno::Any> aParams;
3405 uno::Sequence<sal_Int16> aOutArgsIndex;
3406 uno::Sequence<uno::Any> aOutArgs;
3413 uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( rDoc.
GetVbaEventProcessor(), uno::UNO_SET_THROW );
3414 uno::Sequence< uno::Any > aArgs{
uno::Any(nTab) };
3417 catch( uno::Exception& )
3441 officecfg::Office::Common::Misc::UseOpenCL::set(bEnable, batch);
3449#if HAVE_FEATURE_OPENCL
3450 sc::FormulaGroupInterpreter::switchOpenCLDevice(
u"",
true);
3465 SC_MOD()->SetFormulaOptions(aOptions);
3466#if !HAVE_FEATURE_OPENCL
3469 sc::FormulaGroupInterpreter::switchOpenCLDevice(
u"",
true, bForce);
3480 SC_MOD()->SetFormulaOptions(aOptions);
3485 if(nPlatform < 0 || nDevice < 0)
3486 throw uno::RuntimeException();
3488#if !HAVE_FEATURE_OPENCL
3489 throw uno::RuntimeException();
3491 std::vector<OpenCLPlatformInfo> aPlatformInfo;
3492 sc::FormulaGroupInterpreter::fillOpenCLInfo(aPlatformInfo);
3494 throw uno::RuntimeException();
3497 throw uno::RuntimeException();
3499 OUString aDeviceString = aPlatformInfo[nPlatform].maVendor +
" " + aPlatformInfo[nPlatform].maDevices[nDevice].maName;
3500 sc::FormulaGroupInterpreter::switchOpenCLDevice(aDeviceString,
false);
3506#if !HAVE_FEATURE_OPENCL
3509 sal_Int32 nPlatformId;
3510 sal_Int32 nDeviceId;
3511 sc::FormulaGroupInterpreter::getOpenCLDeviceInfo(nDeviceId, nPlatformId);
3518#if !HAVE_FEATURE_OPENCL
3521 sal_Int32 nPlatformId;
3522 sal_Int32 nDeviceId;
3523 sc::FormulaGroupInterpreter::getOpenCLDeviceInfo(nDeviceId, nPlatformId);
3530#if !HAVE_FEATURE_OPENCL
3531 return uno::Sequence<sheet::opencl::OpenCLPlatform>();
3533 std::vector<OpenCLPlatformInfo> aPlatformInfo;
3534 sc::FormulaGroupInterpreter::fillOpenCLInfo(aPlatformInfo);
3536 uno::Sequence<sheet::opencl::OpenCLPlatform> aRet(aPlatformInfo.size());
3537 auto aRetRange = asNonConstRange(aRet);
3538 for(
size_t i = 0;
i < aPlatformInfo.size(); ++
i)
3540 aRetRange[
i].Name = aPlatformInfo[
i].maName;
3541 aRetRange[
i].Vendor = aPlatformInfo[
i].maVendor;
3543 aRetRange[
i].Devices.realloc(aPlatformInfo[
i].maDevices.size());
3544 auto pDevices = aRetRange[
i].Devices.getArray();
3545 for(
size_t j = 0; j < aPlatformInfo[
i].maDevices.size(); ++j)
3548 pDevices[j].Name = rDevice.
maName;
3549 pDevices[j].Vendor = rDevice.
maVendor;
3550 pDevices[j].Driver = rDevice.
maDriver;
3561void setOpcodeSubsetTest(
bool bFlag)
3564 officecfg::Office::Calc::Formula::Calculation::OpenCLSubsetOnly::set(bFlag, batch);
3572 setOpcodeSubsetTest(
true);
3577 setOpcodeSubsetTest(
false);
3582 return officecfg::Office::Calc::Formula::Calculation::OpenCLSubsetOnly::get();
3588 officecfg::Office::Calc::Formula::Calculation::OpenCLMinimumDataSize::set(number, batch);
3594 return officecfg::Office::Calc::Formula::Calculation::OpenCLMinimumDataSize::get();
3615 if ( rHint.
GetId() == SfxHintId::Dying )
3626 OSL_ENSURE(pDrawLayer,
"Cannot create Draw-Layer");
3627 if ( pDrawLayer &&
nIndex >= 0 && nIndex < pDocShell->GetDocument().GetTableCount() )
3630 OSL_ENSURE(pPage,
"Draw-Page not found");
3633 return uno::Reference<drawing::XDrawPage> (pPage->
getUnoPage(), uno::UNO_QUERY);
3645 uno::Reference<drawing::XDrawPage> xRet;
3651 aNewName,
true,
true ) )
3660 SvxDrawPage* pImp = comphelper::getFromUnoTunnel<SvxDrawPage>( xPage );
3687 throw lang::IndexOutOfBoundsException();
3721 if ( rHint.
GetId() == SfxHintId::Dying )
3731 if (
pDocShell &&
nIndex >= 0 && nIndex < pDocShell->GetDocument().GetTableCount() )
3757 throw uno::RuntimeException(
"ScTableSheetsObj::insertNewByName(): Illegal object name or bad index. Duplicate name?");
3771 throw uno::RuntimeException();
3775 const OUString& aCopy, sal_Int16 nDestination )
3788 SCTAB nResultTab =
static_cast<SCTAB>(nDestination);
3790 if (nResultTab >= nTabCount)
3791 nResultTab = nTabCount - 1;
3799 throw uno::RuntimeException(
"ScTableSheetsObj::copyByName(): Illegal object name or bad index. Duplicate name?");
3806 bool bIllArg =
false;
3812 uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY);
3813 if ( xInterface.is() )
3816 if ( pSheetObj && !pSheetObj->GetDocShell() )
3823 throw container::ElementExistException();
3842 throw lang::IllegalArgumentException();
3844 throw uno::RuntimeException();
3852 bool bIllArg =
false;
3858 uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY);
3859 if ( xInterface.is() )
3862 if ( pSheetObj && !pSheetObj->GetDocShell() )
3868 throw container::NoSuchElementException();
3890 throw lang::IllegalArgumentException();
3892 throw uno::RuntimeException();
3904 throw container::NoSuchElementException();
3909 throw uno::RuntimeException();
3913 const uno::Reference < sheet::XSpreadsheetDocument > & xDocSrc,
3914 const OUString& srcName,
const sal_Int32 nDestPosition )
3920 if ( !xDocSrc.is() )
3921 throw uno::RuntimeException();
3922 ScModelObj* pObj = comphelper::getFromUnoTunnel<ScModelObj>(xDocSrc);
3928 throw lang::IllegalArgumentException();
3932 SCTAB nIndexDest =
static_cast<SCTAB>(nDestPosition);
3933 if (nIndexDest >
nCount || nIndexDest < 0)
3934 throw lang::IndexOutOfBoundsException();
3938 *pDocShellSrc, nIndexSrc, nIndexDest,
true,
true );
3950 throw lang::IndexOutOfBoundsException();
3952 return xSheet->getCellByPosition(nColumn, nRow);
3960 throw lang::IndexOutOfBoundsException();
3962 return xSheet->getCellRangeByPosition(nLeft, nTop, nRight, nBottom);
3968 uno::Sequence < uno::Reference < table::XCellRange > > xRet;
3973 throw lang::IllegalArgumentException();
3977 throw lang::IllegalArgumentException();
3980 auto pRet = xRet.getArray();
4013 throw lang::IndexOutOfBoundsException();
4038 throw container::NoSuchElementException();
4052 OUString* pAry =
aSeq.getArray();
4060 return uno::Sequence<OUString>();
4076 pDocShell( pDocSh ),
4098 else if ( rHint.
GetId() == SfxHintId::Dying )
4141 throw uno::RuntimeException();
4160 throw uno::RuntimeException();
4184 throw lang::IndexOutOfBoundsException();
4206 throw container::NoSuchElementException();
4216 OUString* pAry =
aSeq.getArray();
4238 static uno::Reference<beans::XPropertySetInfo> aRef(
4244 const OUString& aPropertyName,
const uno::Any& aValue )
4248 throw uno::RuntimeException();
4255 sal_Int32 nNewWidth = 0;
4256 if ( aValue >>= nNewWidth )
4291 throw uno::RuntimeException();
4331 pDocShell( pDocSh ),
4336 pDocShell->GetDocument().AddUnoObject(*
this);
4353 else if ( rHint.
GetId() == SfxHintId::Dying )
4386 throw uno::RuntimeException();
4402 throw uno::RuntimeException();
4426 throw lang::IndexOutOfBoundsException();
4446 static uno::Reference<beans::XPropertySetInfo> aRef(
4452 const OUString& aPropertyName,
const uno::Any& aValue )
4456 throw uno::RuntimeException();
4464 sal_Int32 nNewHeight = 0;
4486 sal_Int32 nNewHeight = 0;
4487 if ( aValue >>= nNewHeight )
4543 xRangeObj->setPropertyValue( aPropertyName, aValue );
4551 throw uno::RuntimeException();
4597 aAny = xRangeObj->getPropertyValue( aPropertyName );
4617 const OUString& ,
const uno::Any& )
4629 pDocShell( pDocSh ),
4632 pDocShell->GetDocument().AddUnoObject(*
this);
4647 if ( rHint.
GetId() == SfxHintId::Dying )
4677 const table::CellAddress& aPosition,
const OUString& rText )
4682 OSL_ENSURE( aPosition.Sheet ==
nTab,
"addAnnotation with a wrong Sheet" );
4712 return new ScIndexEnumeration(
this,
"com.sun.star.sheet.CellAnnotationsEnumeration");
4734 if (!xAnnotation.is())
4735 throw lang::IndexOutOfBoundsException();
4752 pDocShell( pDocSh ),
4772 else if ( rHint.
GetId() == SfxHintId::Dying )
4791 if (aTabName == rName)
4820 const uno::Sequence<table::CellRangeAddress>& aRanges,
4821 const OUString& aComment )
4830 for (
const table::CellRangeAddress& rRange : aRanges)
4832 OSL_ENSURE( rRange.Sheet ==
nTab,
"addScenario with a wrong Tab" );
4834 static_cast<SCCOL>(rRange.EndColumn),
static_cast<SCROW>(rRange.EndRow),
nTab );
4874 while (nNext < nTabCount && rDoc.
IsScenario(nNext))
4889 throw lang::IndexOutOfBoundsException();
4910 throw container::NoSuchElementException();
4925 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 void paintControlTile(const SdrPage *pPage, const SdrView *pDrawView, vcl::Window const &rMainWindow, VirtualDevice &rDevice, Size aOutputSize, tools::Rectangle const &rTileRect)
static bool postMouseEvent(const SdrPage *pPage, const SdrView *pDrawView, vcl::DocWindow &rMainWindow, int nType, Point aPointHmm, int nCount, int nButtons, int nModifier)
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=n