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;
557 SCCOL nTiledRenderingAreaEndCol = 0;
558 SCROW nTiledRenderingAreaEndRow = 0;
563 pGridWindow->
PaintTile( rDevice, nOutputWidth, nOutputHeight,
564 nTilePosX, nTilePosY, nTileWidth, nTileHeight,
565 nTiledRenderingAreaEndCol, nTiledRenderingAreaEndRow );
572 Size aOutputSize(nOutputWidth, nOutputHeight);
613 const bool bIsSelected =
false;
616 OUString aPartInfo =
"{ \"visible\": \"" +
617 OUString::number(
static_cast<unsigned int>(bIsVisible)) +
618 "\", \"selected\": \"" +
619 OUString::number(
static_cast<unsigned int>(bIsSelected)) +
620 "\", \"rtllayout\": \"" +
621 OUString::number(
static_cast<unsigned int>(bIsRTLLayout)) +
644 return (pViewData->
GetDocument().
GetHashCode(nPart, nHashCode) ? OUString::number(nHashCode) : OUString());
665 SCCOL nTiledRenderingAreaEndCol = 0;
666 SCROW nTiledRenderingAreaEndRow = 0;
667 return getDocumentSize(nTiledRenderingAreaEndCol, nTiledRenderingAreaEndRow);
679 rnTiledRenderingAreaEndCol = 0;
680 rnTiledRenderingAreaEndRow = 0;
686 const double fPPTX = pViewData->
GetPPTX();
687 const double fPPTY = pViewData->
GetPPTY();
689 auto GetColWidthPx = [pThisDoc, fPPTX, nTab](
SCCOL nCol) {
690 const sal_uInt16 nSize = pThisDoc->
GetColWidth(nCol, nTab);
697 if (nDocWidthPixel > 0 && nDocHeightPixel > 0)
700 aSize.
setWidth(nDocWidthPixel / fPPTX);
701 aSize.
setHeight(nDocHeightPixel / fPPTY);
731 aSize =
Size(nEndCol, nEndRow);
763 nButtons, nModifier, pViewData->
GetPPTX(),
764 pViewData->
GetPPTY(), bDrawNegativeX))
767 Point aPointTwip(nX, nY);
771 Point aPointHMMDraw(bDrawNegativeX ? -aPointHMM.
X() : aPointHMM.
X(), aPointHMM.
Y());
787 aData.setLogicPosition(aPointHMM);
790 case LOK_MOUSEEVENT_MOUSEBUTTONDOWN:
791 aEvent = VclEventId::WindowMouseButtonDown;
793 case LOK_MOUSEEVENT_MOUSEBUTTONUP:
794 aEvent = VclEventId::WindowMouseButtonUp;
796 case LOK_MOUSEEVENT_MOUSEMOVE:
797 aEvent = VclEventId::WindowMouseMove;
823 bool bHandled =
false;
837 case LOK_SETTEXTSELECTION_START:
840 case LOK_SETTEXTSELECTION_END:
843 case LOK_SETTEXTSELECTION_RESET:
853 else if (pDrawView && pDrawView->
IsTextEdit())
862 case LOK_SETTEXTSELECTION_START:
865 case LOK_SETTEXTSELECTION_END:
868 case LOK_SETTEXTSELECTION_RESET:
895 uno::Reference<datatransfer::XTransferable> xTransferable;
899 if (
ScEditShell * pShell =
dynamic_cast<ScEditShell*
>( pViewData->GetViewShell()->GetViewFrame().GetDispatcher()->GetShell(0) ) )
901 else if (
nullptr !=
dynamic_cast<ScDrawTextObjectBar*
>( pViewData->GetViewShell()->GetViewFrame().GetDispatcher()->GetShell(0) ))
903 ScDrawView* pView = pViewData->GetScDrawView();
908 else if (
ScDrawShell * pDrawShell =
dynamic_cast<ScDrawShell*
>( pViewData->GetViewShell()->GetViewFrame().GetDispatcher()->GetShell(0) ) )
909 xTransferable = pDrawShell->GetDrawView()->CopyToTransferable();
911 xTransferable = pViewData->GetViewShell()->CopyToTransferable();
914 if (!xTransferable.is())
917 return xTransferable;
934 double fPPTX = pViewData->
GetPPTX();
935 double fPPTY = pViewData->
GetPPTY();
942 int nPixelX = nX * fPPTX;
943 int nPixelY = nY * fPPTY;
947 case LOK_SETGRAPHICSELECTION_START:
955 case LOK_SETGRAPHICSELECTION_END:
1047 constexpr double fEps = 1
E-08;
1049 if (pViewData->
GetZoomX() == newZoomX && pViewData->
GetZoomY() == newZoomY && fDeltaPPTX < fEps && fDeltaPPTY < fEps)
1052 pViewData->
SetZoom(newZoomX, newZoomY,
true);
1059 pDrawView->resetGridOffsetsForAllSdrPageViews();
1076 bool bFiltered,
bool bGroups)
1101 rJsonWriter.
put(
"commandName",
".uno:CellCursor");
1111 return PointerStyle::Arrow;
1115 return PointerStyle::Arrow;
1125 pChangeTrack->GetChangeTrackInfo(rJson);
1142 comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs))
1168 std::vector<sc::NoteEntry> aNotes;
1171 auto commentsNode = rJsonWriter.
startArray(
"comments");
1176 rJsonWriter.
put(
"id", aNote.mpNote->GetId());
1177 rJsonWriter.
put(
"tab", aNote.maPos.Tab());
1178 rJsonWriter.
put(
"author", aNote.mpNote->GetAuthor());
1179 rJsonWriter.
put(
"dateTime", aNote.mpNote->GetDate());
1180 rJsonWriter.
put(
"text", aNote.mpNote->GetText());
1188 SCCOL nX = aNote.maPos.Col();
1189 SCROW nY = aNote.maPos.Row();
1190 Point aScrPos = pViewData->GetScrPos(nX, nY, pViewData->GetActivePart(),
true);
1193 pViewData->GetMergeSizePixel(nX, nY, nSizeXPix, nSizeYPix);
1195 double fPPTX = pViewData->GetPPTX();
1196 double fPPTY = pViewData->GetPPTY();
1198 Size(nSizeXPix / fPPTX, nSizeYPix / fPPTY));
1212 std::vector<sc::NoteEntry> aNotes;
1215 auto commentsNode = rJsonWriter.
startArray(
"commentsPos");
1220 rJsonWriter.
put(
"id", aNote.mpNote->GetId());
1221 rJsonWriter.
put(
"tab", aNote.maPos.Tab());
1229 SCCOL nX = aNote.maPos.Col();
1230 SCROW nY = aNote.maPos.Row();
1231 Point aScrPos = pViewData->GetScrPos(nX, nY, pViewData->GetActivePart(),
true);
1234 pViewData->GetMergeSizePixel(nX, nY, nSizeXPix, nSizeYPix);
1236 double fPPTX = pViewData->GetPPTX();
1237 double fPPTY = pViewData->GetPPTY();
1239 Size(nSizeXPix / fPPTX, nSizeYPix / fPPTY));
1252 assert(!rFunctionName.isEmpty());
1259 OStringBuffer aState;
1268 aState.append(aThemeName);
1271 return aState.makeStringAndClear();
1281 SC_MOD()->SetAppOptions(aAppOptions);
1283 for (
const beans::PropertyValue& rValue : rArguments)
1285 if (rValue.Name ==
".uno:SpellOnline" && rValue.Value.has<
bool>())
1297 SC_MOD()->SetInputOptions(aInputOptions);
1305 officecfg::Office::Common::Save::Document::WarnAlienFormat::set(
false, xChanges);
1340 aRet =
xNumberAgg->queryAggregation( rType );
1358 static const uno::Sequence<uno::Type>
aTypes = [&]()
1360 uno::Sequence<uno::Type> aAggTypes;
1368 aAggTypes = (*xNumProv)->getTypes();
1374 uno::Sequence<uno::Type>
1399 return css::uno::Sequence<sal_Int8>();
1407 if (
nId == SfxHintId::Dying )
1413 comphelper::getFromUnoTunnel<SvNumberFormatsSupplierObj>(
1414 uno::Reference<util::XNumberFormatsSupplier>(
xNumberAgg, uno::UNO_QUERY) );
1422 else if (
nId == SfxHintId::DataChanged )
1466 return css::uno::Reference< ::css::chart2::data::XDataProvider > (
1487 for (
const beans::PropertyValue& rProp : rOptions)
1489 const OUString & rPropName = rProp.Name;
1493 uno::Reference<awt::XDevice> xRenderDevice(rProp.Value, uno::UNO_QUERY);
1494 if ( xRenderDevice.is() )
1515 sal_Int32 nNumeric = 0;
1517 bool bRangeValid =
false;
1518 bool bRectValid =
false;
1526 rTargetRange = aAddress;
1535 ( nNumeric =
rTarget.toInt32() ) > 0 && nNumeric <= rDoc.
MaxRow()+1 )
1538 rTargetRange =
ScAddress( 0,
static_cast<SCROW>(nNumeric-1), nSourceTab );
1555 for (
SCTAB i=0;
i<nTabCount && !bRangeValid;
i++)
1558 OSL_ENSURE(pPage,
"Page ?");
1563 while (
pObject && !bRangeValid)
1567 rTargetRect =
pObject->GetLogicRect();
1568 rTargetRange = rDoc.
GetRange(
i, rTargetRect );
1569 bRangeValid = bRectValid =
true;
1577 if ( bRangeValid && !bRectValid )
1589 const uno::Sequence< beans::PropertyValue >& rOptions,
1592 bool& rbRenderToGraphic )
const
1594 OSL_ENSURE( !rMark.
IsMarked() && !rMark.
IsMultiMarked(),
"FillRenderMarkData: MarkData must be empty" );
1595 OSL_ENSURE(
pDocShell,
"FillRenderMarkData: DocShell must be set" );
1599 uno::Reference<frame::XController> xView;
1602 bool bSelectedSheetsOnly =
false;
1603 bool bSuppressEmptyPages =
true;
1605 bool bHasPrintContent =
false;
1606 sal_Int32 nPrintContent = 0;
1607 sal_Int32 nPrintRange = 0;
1608 sal_Int32 nEOContent = 0;
1609 OUString aPageRange;
1611 for(
const auto& rOption : rOptions )
1613 if ( rOption.Name ==
"IsOnlySelectedSheets" )
1615 rOption.Value >>= bSelectedSheetsOnly;
1617 else if ( rOption.Name ==
"IsSuppressEmptyPages" )
1619 rOption.Value >>= bSuppressEmptyPages;
1621 else if ( rOption.Name ==
"PageRange" )
1623 rOption.Value >>= aPageRange;
1625 else if ( rOption.Name ==
"PrintRange" )
1627 rOption.Value >>= nPrintRange;
1629 else if ( rOption.Name ==
"EvenOdd" )
1631 rOption.Value >>= nEOContent;
1633 else if ( rOption.Name ==
"PrintContent" )
1635 bHasPrintContent =
true;
1636 rOption.Value >>= nPrintContent;
1638 else if ( rOption.Name ==
"View" )
1640 rOption.Value >>= xView;
1642 else if ( rOption.Name ==
"RenderToGraphic" )
1644 rOption.Value >>= rbRenderToGraphic;
1649 if ( bHasPrintContent )
1650 bSelectedSheetsOnly = ( nPrintContent != 0 );
1652 uno::Reference<uno::XInterface> xInterface(aSelection, uno::UNO_QUERY);
1653 if ( xInterface.is() )
1655 ScCellRangesBase* pSelObj =
dynamic_cast<ScCellRangesBase*
>( xInterface.get() );
1656 uno::Reference< drawing::XShapes > xShapes( xInterface, uno::UNO_QUERY );
1657 if ( pSelObj && pSelObj->GetDocShell() ==
pDocShell )
1659 bool bSheet = (
dynamic_cast<ScTableSheetObj*
>( pSelObj ) !=
nullptr );
1660 bool bCursor = pSelObj->IsCursorOnly();
1661 const ScRangeList& rRanges = pSelObj->GetRangeList();
1679 if ( bCursor || bSheet )
1692 else if( xShapes.is() )
1696 uno::Reference< drawing::XShape > xShape( xShapes->getByIndex(0), uno::UNO_QUERY );
1713 else if ( comphelper::getFromUnoTunnel<ScModelObj>( xInterface ) ==
this )
1719 for (
SCTAB nTab = 0; nTab < nTabCount; nTab++)
1728 uno::Reference<sheet::XSelectedSheetsSupplier> xSelectedSheets(xView, uno::UNO_QUERY);
1729 if (bSelectedSheetsOnly &&
pDocShell && xSelectedSheets.is())
1731 const uno::Sequence<sal_Int32> aSelected = xSelectedSheets->getSelectedSheets();
1734 for (
const auto& rSelected : aSelected)
1736 SCTAB nSelected =
static_cast<SCTAB>(rSelected);
1738 aSelectedTabs.insert(nSelected);
1749 if ( nPrintRange == 1 )
1750 rPagesStr = aPageRange;
1758 const uno::Sequence<beans::PropertyValue>& rOptions)
1763 throw lang::DisposedException( OUString(),
1764 static_cast< sheet::XSpreadsheetDocument*
>(
this) );
1770 bool bRenderToGraphic =
false;
1771 if ( !
FillRenderMarkData( aSelection, rOptions, aMark, aStatus, aPagesStr, bRenderToGraphic ) )
1787 sal_Int32 nContent = 0;
1788 sal_Int32 nEOContent = 0;
1789 bool bSinglePageSheets =
false;
1790 for (
const auto& rValue : rOptions)
1792 if ( rValue.Name ==
"PrintRange" )
1794 rValue.Value >>= nContent;
1796 else if ( rValue.Name ==
"SinglePageSheets" )
1798 rValue.Value >>= bSinglePageSheets;
1800 else if ( rValue.Name ==
"EvenOdd" )
1802 rValue.Value >>= nEOContent;
1806 if (bSinglePageSheets)
1811 bool bIsPrintEvenPages = (nEOContent != 1 && nContent == 0) || nContent != 0;
1812 bool bIsPrintOddPages = (nEOContent != 2 && nContent == 0) || nContent != 0;
1814 for ( sal_Int32 nPage = 1; nPage <= nPages; nPage++ )
1820 sal_Int32 nSelectCount =
static_cast<sal_Int32
>(
maValidPages.size() );
1822 if ( nEOContent == 1 || nEOContent == 2 )
1823 return nSelectCount;
1825 if ( !aPagesStr.isEmpty() )
1828 nSelectCount = aRangeEnum.
size();
1830 return (nSelectCount > 0) ? nSelectCount : 1;
1833static sal_Int32
lcl_GetRendererNum( sal_Int32 nSelRenderer, std::u16string_view rPagesStr, sal_Int32 nTotalPages )
1835 if ( rPagesStr.empty() )
1836 return nSelRenderer;
1841 for ( ; nSelRenderer > 0 && aIter != aEnd; --nSelRenderer )
1853 const uno::Any& aSelection,
const uno::Sequence<beans::PropertyValue>& rOptions )
1858 throw lang::DisposedException( OUString(),
1859 static_cast< sheet::XSpreadsheetDocument*
>(
this) );
1867 bool bRenderToGraphic =
false;
1868 bool bSinglePageSheets =
false;
1869 if (
FillRenderMarkData( aSelection, rOptions, aMark, aStatus, aPagesStr, bRenderToGraphic ) )
1878 for (
const auto& rValue : rOptions)
1880 if ( rValue.Name ==
"SinglePageSheets" )
1882 rValue.Value >>= bSinglePageSheets;
1887 if (bSinglePageSheets)
1892 if ( nRenderer < 0 )
1894 if ( nSelRenderer != 0 )
1895 throw lang::IllegalArgumentException();
1899 awt::Size aPageSize;
1907 aPageSize.Width = aMMRect.
GetWidth();
1912 SCTAB const nCurTab = 0;
1935 if (bSinglePageSheets)
1936 nTab = nSelRenderer;
1944 const ScRange* pSelRange =
nullptr;
1945 if ( bSinglePageSheets )
1958 table::CellRangeAddress aRangeAddress( nTab,
1966 const awt::Point aCalcPagePos(aMMRect.
Left(), aMMRect.
Top());
1968 uno::Sequence<beans::PropertyValue> aSequence
1988 pSelRange = &aRange;
1991 awt::Size aPageSize;
1992 bool bWasCellRange =
false;
1996 bWasCellRange =
true;
1997 aCellRange = aRange;
2001 aPageSize.Width = aMMRect.
GetWidth();
2006 std::unique_ptr<ScPrintFunc, o3tl::default_delete<ScPrintFunc>> pPrintFunc;
2012 pPrintFunc->SetRenderFlag(
true );
2014 sal_Int32 nContent = 0;
2015 sal_Int32 nEOContent = 0;
2016 for (
const auto& rValue : rOptions)
2018 if ( rValue.Name ==
"PrintRange" )
2020 rValue.Value >>= nContent;
2022 else if ( rValue.Name ==
"EvenOdd" )
2024 rValue.Value >>= nEOContent;
2031 bool bOddOrEven = (nContent == 0 && nEOContent == 1) || (nContent == 1 && nEOContent == 2);
2038 aPage.
Select( nRenderer+1 );
2043 (void)pPrintFunc->DoPrint( aPage, nTabStart, nDisplayStart,
false,
nullptr );
2045 bWasCellRange = pPrintFunc->GetLastSourceRange( aCellRange );
2046 Size aTwips = pPrintFunc->GetPageSize();
2059 uno::Sequence<beans::PropertyValue> aSequence(nPropCount);
2060 beans::PropertyValue* pArray = aSequence.getArray();
2062 pArray[0].Value <<= aPageSize;
2065 pArray[1].Value <<=
true;
2066 if ( bWasCellRange )
2068 table::CellRangeAddress aRangeAddress( nTab,
2076 const awt::Point aCalcPagePos(aMMRect.
Left(), aMMRect.
Top());
2079 pArray[2].Value <<= aRangeAddress;
2081 pArray[3].Value <<= aCalcPageSize;
2083 pArray[4].Value <<= aCalcPagePos;
2095 const uno::Sequence<beans::PropertyValue>& rOptions )
2100 throw lang::DisposedException( OUString(),
2101 static_cast< sheet::XSpreadsheetDocument*
>(
this) );
2107 bool bRenderToGraphic =
false;
2108 bool bSinglePageSheets =
false;
2109 if ( !
FillRenderMarkData( aSelection, rOptions, aMark, aStatus, aPagesStr, bRenderToGraphic ) )
2110 throw lang::IllegalArgumentException();
2118 for (
const auto& rValue : rOptions)
2120 if ( rValue.Name ==
"SinglePageSheets" )
2122 rValue.Value >>= bSinglePageSheets;
2127 if (bSinglePageSheets)
2131 if ( nRenderer < 0 )
2132 throw lang::IllegalArgumentException();
2136 throw lang::IllegalArgumentException();
2141 const ScRange* pSelRange =
nullptr;
2142 if ( bSinglePageSheets )
2144 awt::Size aPageSize;
2147 rDoc.
GetDataStart( nSelRenderer, nStartCol, nStartRow );
2159 aPageSize.Width = aMMRect.
GetWidth();
2164 if (nVisTab != nSelRenderer)
2166 nVisTab = nSelRenderer;
2177 pSelRange = &aRange;
2191 const double nPrintFactor = 1.0;
2200 struct DrawViewKeeper
2202 std::unique_ptr<FmFormView> mpDrawView;
2208 mpDrawView->HideSdrPage();
2224 aDrawViewKeeper.mpDrawView.reset(
new FmFormView(
2227 aDrawViewKeeper.mpDrawView->ShowSdrPage(aDrawViewKeeper.mpDrawView->GetModel().GetPage(nTab));
2228 aDrawViewKeeper.mpDrawView->SetPrintPreview();
2235 std::unique_ptr<ScPrintFunc, o3tl::default_delete<ScPrintFunc>> pPrintFunc;
2242 pPrintFunc->SetDrawView( aDrawViewKeeper.mpDrawView.get() );
2243 pPrintFunc->SetRenderFlag(
true );
2245 pPrintFunc->SetExclusivelyDrawOleAndDrawObjects();
2247 sal_Int32 nContent = 0;
2248 sal_Int32 nEOContent = 0;
2249 for (
const auto& rValue : rOptions)
2251 if ( rValue.Name ==
"PrintRange" )
2253 rValue.Value >>= nContent;
2255 else if ( rValue.Name ==
"EvenOdd" )
2257 rValue.Value >>= nEOContent;
2264 bool bOddOrEven = (nContent == 0 && nEOContent == 1) || (nContent == 0 && nEOContent == 2);
2271 aPage.
Select( nRenderer+1 );
2277 if ( nRenderer == nTabStart )
2291 sal_Int32 nDestID = pPDFData->
CreateDest( aArea );
2293 rDoc.
GetName( nTab, aTabName );
2302 rDoc.
GetName( nTab, aTabName );
2308 (void)pPrintFunc->DoPrint( aPage, nTabStart, nDisplayStart,
true,
nullptr );
2323 std::vector< vcl::PDFExtOutDevBookmarkEntry >& rBookmarks = pPDFData->
GetBookmarks();
2324 for (
const auto& rBookmark : rBookmarks )
2326 OUString aBookmark = rBookmark.aBookmark;
2327 if ( aBookmark.toChar() ==
'#' )
2331 OUString aTarget( aBookmark.copy( 1 ) );
2335 bool bIsSheet =
false;
2336 bool bValid =
lcl_ParseTarget( aTarget, aTargetRange, aTargetRect, bIsSheet, rDoc, nTab );
2340 sal_Int32 nPage = -1;
2356 nPage = aLocation.
nPage;
2378 if ( nX1 > aLocationPixel.
Right() ) nX1 = aLocationPixel.
Right();
2379 if ( nX2 > aLocationPixel.
Right() ) nX2 = aLocationPixel.
Right();
2380 if ( nY1 > aLocationPixel.
Bottom() ) nY1 = aLocationPixel.
Bottom();
2381 if ( nY2 > aLocationPixel.
Bottom() ) nY2 = aLocationPixel.
Bottom();
2397 pPDFData->
SetLinkURL( rBookmark.nLinkId, aBookmark );
2418 bool bLocked =
false;
2448 sal_uInt16 nRet = 0;
2488 OSL_FAIL(
"no DocShell");
2502 OSL_FAIL(
"no DocShell");
2512 OSL_FAIL(
"no DocShell");
2518 bool bEnabled(bEnabledIn);
2531 OSL_FAIL(
"no DocShell");
2554 throw lang::IllegalArgumentException();
2564 OSL_FAIL(
"no DocShell");
2576 OSL_FAIL(
"no DocShell");
2583 const table::CellAddress& aFormulaPosition,
2584 const table::CellAddress& aVariablePosition,
2585 const OUString& aGoalValue )
2588 sheet::GoalResult aResult;
2589 aResult.Divergence = DBL_MAX;
2594 double fValue = 0.0;
2595 bool bFound = rDoc.
Solver(
2596 static_cast<SCCOL>(aFormulaPosition.Column),
static_cast<SCROW>(aFormulaPosition.Row), aFormulaPosition.Sheet,
2597 static_cast<SCCOL>(aVariablePosition.Column),
static_cast<SCROW>(aVariablePosition.Row), aVariablePosition.Sheet,
2598 aGoalValue, fValue );
2599 aResult.Result = fValue;
2601 aResult.Divergence = 0.0;
2618 pNew->SetParam( *pParam );
2624 const uno::Reference<sheet::XConsolidationDescriptor>& xDescriptor )
2633 xImpl->setFunction( xDescriptor->getFunction() );
2634 xImpl->setSources( xDescriptor->getSources() );
2635 xImpl->setStartOutputPosition( xDescriptor->getStartOutputPosition() );
2636 xImpl->setUseColumnHeaders( xDescriptor->getUseColumnHeaders() );
2637 xImpl->setUseRowHeaders( xDescriptor->getUseRowHeaders() );
2638 xImpl->setInsertLinks( xDescriptor->getInsertLinks() );
2674 uno::Sequence< beans::PropertyValue >
aSeq{
2692 static uno::Reference<beans::XPropertySetInfo> aRef(
2698 const OUString& aPropertyName,
const uno::Any& aValue )
2720 bHardRecalc =
false;
2724 lang::Locale aLocale;
2725 if ( aValue >>= aLocale )
2736 if ( aValue >>= sCodeName )
2741 lang::Locale aLocale;
2742 if ( aValue >>= aLocale )
2752 lang::Locale aLocale;
2753 if ( aValue >>= aLocale )
2769 pBindings->
Invalidate( SID_FM_OPEN_READONLY );
2779 pBindings->
Invalidate( SID_FM_AUTOCONTROLFOCUS );
2791 ? officecfg::Office::Common::Undo::Steps::get() : 0);
2797 bool bChangeAllowed =
true;
2798 if (!bRecordChangesEnabled)
2819 else if ( aPropertyName ==
"BuildId" )
2823 else if ( aPropertyName ==
"SavedObject" )
2826 aValue >>= aObjName;
2827 if ( !aObjName.isEmpty() )
2835 if ( aNewOpt != rOldOpt )
2864 lang::Locale aLocale;
2878 lang::Locale aLocale;
2887 lang::Locale aLocale;
2932 aRet <<= bOpenInDesign;
2939 aRet <<= bAutoControlFocus;
2964 aRet <<= OUString(
"ThisExcelDoc" );
3006 aRet <<= uno::Reference< awt::XDevice >( pXDev );
3008 else if ( aPropertyName ==
"BuildId" )
3012 else if ( aPropertyName ==
"InternalDocument" )
3030 OUString const & aServiceSpecifier,
3031 css::
uno::Sequence<css::
uno::Any> const * arguments)
3035 uno::Reference<uno::XInterface> xRet;
3037 if (
nType != ServiceType::INVALID )
3043 case ServiceType::GRADTAB: xRet.set(xDrawGradTab);
break;
3044 case ServiceType::HATCHTAB: xRet.set(xDrawHatchTab);
break;
3045 case ServiceType::BITMAPTAB: xRet.set(xDrawBitmapTab);
break;
3046 case ServiceType::TRGRADTAB: xRet.set(xDrawTrGradTab);
break;
3047 case ServiceType::MARKERTAB: xRet.set(xDrawMarkerTab);
break;
3048 case ServiceType::DASHTAB: xRet.set(xDrawDashTab);
break;
3049 case ServiceType::CHDATAPROV: xRet.set(xChartDataProv);
break;
3050 case ServiceType::VBAOBJECTPROVIDER: xRet.set(xObjProvider);
break;
3057 (
nType != ServiceType::CHDATAPROV ||
3058 ( pDocShell->GetCreateMode() != SfxObjectCreateMode::INTERNAL ));
3063 if ( !xRet.is() && bCreate )
3070 case ServiceType::GRADTAB: xDrawGradTab.set(xRet);
break;
3071 case ServiceType::HATCHTAB: xDrawHatchTab.set(xRet);
break;
3072 case ServiceType::BITMAPTAB: xDrawBitmapTab.set(xRet);
break;
3073 case ServiceType::TRGRADTAB: xDrawTrGradTab.set(xRet);
break;
3074 case ServiceType::MARKERTAB: xDrawMarkerTab.set(xRet);
break;
3075 case ServiceType::DASHTAB: xDrawDashTab.set(xRet);
break;
3076 case ServiceType::CHDATAPROV: xChartDataProv.set(xRet);
break;
3077 case ServiceType::VBAOBJECTPROVIDER: xObjProvider.set(xRet);
break;
3089 xRet = arguments ==
nullptr
3092 aServiceSpecifier, *arguments);
3095 catch ( lang::ServiceNotRegisteredException & )
3102 uno::Reference<drawing::XShape> xShape( xRet, uno::UNO_QUERY );
3114 const OUString& aServiceSpecifier )
3117 return create(aServiceSpecifier,
nullptr);
3121 const OUString& ServiceSpecifier,
3122 const uno::Sequence<uno::Any>& aArgs )
3127 uno::Reference<uno::XInterface> xInt(
create(ServiceSpecifier, &aArgs));
3129 if ( aArgs.hasElements() )
3133 uno::Reference<lang::XInitialization> xInit( xInt, uno::UNO_QUERY );
3135 xInit->initialize( aArgs );
3152 return "ScModelObj";
3171 const uno::Sequence<sal_Int8 >& rId )
3173 if ( comphelper::isUnoTunnelId<ScModelObj>(rId) )
3178 if ( comphelper::isUnoTunnelId<SfxObjectShell>(rId) )
3194 if(
auto xTunnelAgg =
o3tl::tryAccess<uno::Reference<lang::XUnoTunnel>>(
3197 return (*xTunnelAgg)->getSomething( rId );
3207 return theScModelObjUnoTunnelId.
getSeq();
3238 bool bInvalidateDataArea,
bool bExtendDataArea)
3240 size_t nRangeCount = rRanges.
size();
3242 for (
size_t nIndex = 0;
nIndex < nRangeCount; ++
nIndex )
3248 bool bAreaExtended =
false;
3250 if (bExtendDataArea)
3257 bAreaExtended = rEnd.
Col() > nLastCol || rEnd.
Row() > nLastRow;
3260 bool bInvalidate = bAreaExtended || bInvalidateDataArea;
3276 const uno::Sequence< beans::PropertyValue >& rProperties )
3278 OUString aOperation = rOperation;
3279 bool bIsDataAreaInvalidateType = aOperation ==
"data-area-invalidate";
3280 bool bIsDataAreaExtendType = aOperation ==
"data-area-extend";
3282 bool bInvalidateDataArea = bIsDataAreaInvalidateType
3284 bool bExtendDataArea = bIsDataAreaExtendType || aOperation ==
"cell-change";
3289 lcl_dataAreaInvalidation(rDocument,
this, rRanges, bInvalidateDataArea, bExtendDataArea);
3292 if (bIsDataAreaInvalidateType || bIsDataAreaExtendType)
3297 if (rOperation ==
"delete-content" || rOperation ==
"undo"
3298 || rOperation ==
"redo" || rOperation ==
"paste")
3299 aOperation =
"cell-change";
3304 util::ChangesEvent
aEvent;
3305 aEvent.Source.set(getXWeak());
3308 size_t nRangeCount = rRanges.
size();
3309 aEvent.Changes.realloc(
static_cast< sal_Int32
>( nRangeCount ) );
3310 auto pChanges =
aEvent.Changes.getArray();
3313 uno::Reference< table::XCellRange > xRangeObj;
3325 util::ElementChange& rChange = pChanges[
static_cast< sal_Int32
>(
nIndex ) ];
3326 rChange.Accessor <<= aOperation;
3327 rChange.Element <<= rProperties;
3328 rChange.ReplacedElement <<= xRangeObj;
3338 catch( uno::Exception& )
3346 if ( !(aOperation ==
"cell-change" &&
pDocShell) )
3353 for (
const SCTAB& nTab : aMarkData)
3355 if (nTab >= nTabCount)
3364 size_t nRangeCount = rRanges.
size();
3371 size_t nTabRangeCount = aTabRanges.
size();
3372 if ( nTabRangeCount > 0 )
3374 uno::Reference<uno::XInterface>
xTarget;
3375 if ( nTabRangeCount == 1 )
3377 ScRange const & rRange = aTabRanges[ 0 ];
3384 xTarget.set( cppu::getXWeak(
new ScCellRangesObj(
pDocShell, aTabRanges ) ) );
3389 uno::Sequence<sal_Int16> aOutArgsIndex;
3390 uno::Sequence<uno::Any> aOutArgs;
3410 for (
SCTAB nTab = 0; nTab < nTabCount; nTab++)
3419 uno::Sequence<uno::Any> aParams;
3420 uno::Sequence<sal_Int16> aOutArgsIndex;
3421 uno::Sequence<uno::Any> aOutArgs;
3428 uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( rDoc.
GetVbaEventProcessor(), uno::UNO_SET_THROW );
3429 uno::Sequence< uno::Any > aArgs{
uno::Any(nTab) };
3432 catch( uno::Exception& )
3456 officecfg::Office::Common::Misc::UseOpenCL::set(bEnable, batch);
3464#if HAVE_FEATURE_OPENCL
3465 sc::FormulaGroupInterpreter::switchOpenCLDevice(
u"",
true);
3480 SC_MOD()->SetFormulaOptions(aOptions);
3481#if !HAVE_FEATURE_OPENCL
3484 sc::FormulaGroupInterpreter::switchOpenCLDevice(
u"",
true, bForce);
3495 SC_MOD()->SetFormulaOptions(aOptions);
3500 if(nPlatform < 0 || nDevice < 0)
3501 throw uno::RuntimeException();
3503#if !HAVE_FEATURE_OPENCL
3504 throw uno::RuntimeException();
3506 std::vector<OpenCLPlatformInfo> aPlatformInfo;
3507 sc::FormulaGroupInterpreter::fillOpenCLInfo(aPlatformInfo);
3509 throw uno::RuntimeException();
3512 throw uno::RuntimeException();
3514 OUString aDeviceString = aPlatformInfo[nPlatform].maVendor +
" " + aPlatformInfo[nPlatform].maDevices[nDevice].maName;
3515 sc::FormulaGroupInterpreter::switchOpenCLDevice(aDeviceString,
false);
3521#if !HAVE_FEATURE_OPENCL
3524 sal_Int32 nPlatformId;
3525 sal_Int32 nDeviceId;
3526 sc::FormulaGroupInterpreter::getOpenCLDeviceInfo(nDeviceId, nPlatformId);
3533#if !HAVE_FEATURE_OPENCL
3536 sal_Int32 nPlatformId;
3537 sal_Int32 nDeviceId;
3538 sc::FormulaGroupInterpreter::getOpenCLDeviceInfo(nDeviceId, nPlatformId);
3545#if !HAVE_FEATURE_OPENCL
3546 return uno::Sequence<sheet::opencl::OpenCLPlatform>();
3548 std::vector<OpenCLPlatformInfo> aPlatformInfo;
3549 sc::FormulaGroupInterpreter::fillOpenCLInfo(aPlatformInfo);
3551 uno::Sequence<sheet::opencl::OpenCLPlatform> aRet(aPlatformInfo.size());
3552 auto aRetRange = asNonConstRange(aRet);
3553 for(
size_t i = 0;
i < aPlatformInfo.size(); ++
i)
3555 aRetRange[
i].Name = aPlatformInfo[
i].maName;
3556 aRetRange[
i].Vendor = aPlatformInfo[
i].maVendor;
3558 aRetRange[
i].Devices.realloc(aPlatformInfo[
i].maDevices.size());
3559 auto pDevices = aRetRange[
i].Devices.getArray();
3560 for(
size_t j = 0; j < aPlatformInfo[
i].maDevices.size(); ++j)
3563 pDevices[j].Name = rDevice.
maName;
3564 pDevices[j].Vendor = rDevice.
maVendor;
3565 pDevices[j].Driver = rDevice.
maDriver;
3576void setOpcodeSubsetTest(
bool bFlag)
3579 officecfg::Office::Calc::Formula::Calculation::OpenCLSubsetOnly::set(bFlag, batch);
3587 setOpcodeSubsetTest(
true);
3592 setOpcodeSubsetTest(
false);
3597 return officecfg::Office::Calc::Formula::Calculation::OpenCLSubsetOnly::get();
3603 officecfg::Office::Calc::Formula::Calculation::OpenCLMinimumDataSize::set(number, batch);
3609 return officecfg::Office::Calc::Formula::Calculation::OpenCLMinimumDataSize::get();
3630 if ( rHint.
GetId() == SfxHintId::Dying )
3641 OSL_ENSURE(pDrawLayer,
"Cannot create Draw-Layer");
3642 if ( pDrawLayer &&
nIndex >= 0 && nIndex < pDocShell->GetDocument().GetTableCount() )
3645 OSL_ENSURE(pPage,
"Draw-Page not found");
3648 return uno::Reference<drawing::XDrawPage> (pPage->
getUnoPage(), uno::UNO_QUERY);
3660 uno::Reference<drawing::XDrawPage> xRet;
3666 aNewName,
true,
true ) )
3675 SvxDrawPage* pImp = comphelper::getFromUnoTunnel<SvxDrawPage>( xPage );
3702 throw lang::IndexOutOfBoundsException();
3736 if ( rHint.
GetId() == SfxHintId::Dying )
3746 if (
pDocShell &&
nIndex >= 0 && nIndex < pDocShell->GetDocument().GetTableCount() )
3772 throw uno::RuntimeException(
"ScTableSheetsObj::insertNewByName(): Illegal object name or bad index. Duplicate name?");
3786 throw uno::RuntimeException();
3790 const OUString& aCopy, sal_Int16 nDestination )
3803 SCTAB nResultTab =
static_cast<SCTAB>(nDestination);
3805 if (nResultTab >= nTabCount)
3806 nResultTab = nTabCount - 1;
3814 throw uno::RuntimeException(
"ScTableSheetsObj::copyByName(): Illegal object name or bad index. Duplicate name?");
3821 bool bIllArg =
false;
3827 uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY);
3828 if ( xInterface.is() )
3831 if ( pSheetObj && !pSheetObj->GetDocShell() )
3838 throw container::ElementExistException();
3857 throw lang::IllegalArgumentException();
3859 throw uno::RuntimeException();
3867 bool bIllArg =
false;
3873 uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY);
3874 if ( xInterface.is() )
3877 if ( pSheetObj && !pSheetObj->GetDocShell() )
3883 throw container::NoSuchElementException();
3905 throw lang::IllegalArgumentException();
3907 throw uno::RuntimeException();
3919 throw container::NoSuchElementException();
3924 throw uno::RuntimeException();
3928 const uno::Reference < sheet::XSpreadsheetDocument > & xDocSrc,
3929 const OUString& srcName,
const sal_Int32 nDestPosition )
3935 if ( !xDocSrc.is() )
3936 throw uno::RuntimeException();
3937 ScModelObj* pObj = comphelper::getFromUnoTunnel<ScModelObj>(xDocSrc);
3943 throw lang::IllegalArgumentException();
3947 SCTAB nIndexDest =
static_cast<SCTAB>(nDestPosition);
3948 if (nIndexDest >
nCount || nIndexDest < 0)
3949 throw lang::IndexOutOfBoundsException();
3953 *pDocShellSrc, nIndexSrc, nIndexDest,
true,
true );
3965 throw lang::IndexOutOfBoundsException();
3967 return xSheet->getCellByPosition(nColumn, nRow);
3975 throw lang::IndexOutOfBoundsException();
3977 return xSheet->getCellRangeByPosition(nLeft, nTop, nRight, nBottom);
3983 uno::Sequence < uno::Reference < table::XCellRange > > xRet;
3988 throw lang::IllegalArgumentException();
3992 throw lang::IllegalArgumentException();
3995 auto pRet = xRet.getArray();
4028 throw lang::IndexOutOfBoundsException();
4053 throw container::NoSuchElementException();
4067 OUString* pAry =
aSeq.getArray();
4075 return uno::Sequence<OUString>();
4091 pDocShell( pDocSh ),
4113 else if ( rHint.
GetId() == SfxHintId::Dying )
4156 throw uno::RuntimeException();
4175 throw uno::RuntimeException();
4199 throw lang::IndexOutOfBoundsException();
4221 throw container::NoSuchElementException();
4231 OUString* pAry =
aSeq.getArray();
4253 static uno::Reference<beans::XPropertySetInfo> aRef(
4259 const OUString& aPropertyName,
const uno::Any& aValue )
4263 throw uno::RuntimeException();
4270 sal_Int32 nNewWidth = 0;
4271 if ( aValue >>= nNewWidth )
4306 throw uno::RuntimeException();
4346 pDocShell( pDocSh ),
4351 pDocShell->GetDocument().AddUnoObject(*
this);
4368 else if ( rHint.
GetId() == SfxHintId::Dying )
4401 throw uno::RuntimeException();
4417 throw uno::RuntimeException();
4441 throw lang::IndexOutOfBoundsException();
4461 static uno::Reference<beans::XPropertySetInfo> aRef(
4467 const OUString& aPropertyName,
const uno::Any& aValue )
4471 throw uno::RuntimeException();
4479 sal_Int32 nNewHeight = 0;
4501 sal_Int32 nNewHeight = 0;
4502 if ( aValue >>= nNewHeight )
4558 xRangeObj->setPropertyValue( aPropertyName, aValue );
4566 throw uno::RuntimeException();
4612 aAny = xRangeObj->getPropertyValue( aPropertyName );
4632 const OUString& ,
const uno::Any& )
4644 pDocShell( pDocSh ),
4647 pDocShell->GetDocument().AddUnoObject(*
this);
4662 if ( rHint.
GetId() == SfxHintId::Dying )
4692 const table::CellAddress& aPosition,
const OUString& rText )
4697 OSL_ENSURE( aPosition.Sheet ==
nTab,
"addAnnotation with a wrong Sheet" );
4727 return new ScIndexEnumeration(
this,
"com.sun.star.sheet.CellAnnotationsEnumeration");
4749 if (!xAnnotation.is())
4750 throw lang::IndexOutOfBoundsException();
4767 pDocShell( pDocSh ),
4787 else if ( rHint.
GetId() == SfxHintId::Dying )
4806 if (aTabName == rName)
4835 const uno::Sequence<table::CellRangeAddress>& aRanges,
4836 const OUString& aComment )
4845 for (
const table::CellRangeAddress& rRange : aRanges)
4847 OSL_ENSURE( rRange.Sheet ==
nTab,
"addScenario with a wrong Tab" );
4849 static_cast<SCCOL>(rRange.EndColumn),
static_cast<SCROW>(rRange.EndRow),
nTab );
4889 while (nNext < nTabCount && rDoc.
IsScenario(nNext))
4904 throw lang::IndexOutOfBoundsException();
4925 throw container::NoSuchElementException();
4940 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