22 #include <config_features.h>
34 #include <rtl/bootstrap.hxx>
35 #include <rtl/tencinfo.h>
49 #include <osl/file.hxx>
52 #include <com/sun/star/awt/Key.hpp>
53 #include <com/sun/star/awt/KeyModifier.hpp>
54 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
55 #include <com/sun/star/document/UpdateDocMode.hpp>
56 #include <com/sun/star/script/vba/VBAEventId.hpp>
57 #include <com/sun/star/script/vba/VBAScriptEventId.hpp>
58 #include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
59 #include <com/sun/star/script/vba/XVBAScriptListener.hpp>
60 #include <com/sun/star/script/vba/XVBACompatibility.hpp>
61 #include <com/sun/star/sheet/XSpreadsheetView.hpp>
62 #include <com/sun/star/task/XJob.hpp>
63 #include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
64 #include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
65 #include <com/sun/star/util/VetoException.hpp>
66 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
67 #include <ooo/vba/excel/XWorkbook.hpp>
70 #include <config_folders.h>
74 #include <svx/dialogs.hrc>
81 #include <docfunc.hxx>
85 #include <strings.hrc>
86 #include <globstr.hrc>
89 #include <stlpool.hxx>
93 #include <progress.hxx>
109 #include <compiler.hxx>
119 #include <officecfg/Office/Calc.hxx>
123 #include <uiitems.hxx>
136 using ::com::sun::star::uno::Reference;
137 using ::com::sun::star::lang::XMultiServiceFactory;
138 using std::shared_ptr;
163 #define ShellClass_ScDocShell
164 #include <scslots.hxx>
178 OUString* pFullTypeName,
179 sal_Int32 nFileFormat,
180 bool bTemplate )
const
185 *pFormat = SotClipboardFormatId::STARCALC_60;
186 *pFullTypeName =
ScResId( SCSTR_LONG_SCDOC_NAME_60 );
191 *pFormat = bTemplate ? SotClipboardFormatId::STARCALC_8_TEMPLATE : SotClipboardFormatId::STARCALC_8;
192 *pFullTypeName =
ScResId( SCSTR_LONG_SCDOC_NAME_80 );
196 OSL_FAIL(
"Which version?");
202 return m_aDocument.GetDocColors();
209 SC_MOD()->InputEnterHandler();
229 if ( nStates & HiddenInformation::RECORDEDCHANGES )
231 if ( m_aDocument.GetChangeTrack() && m_aDocument.GetChangeTrack()->GetFirst() )
232 nState |= HiddenInformation::RECORDEDCHANGES;
234 if ( nStates & HiddenInformation::NOTES )
236 SCTAB nTableCount = m_aDocument.GetTableCount();
238 for (
SCTAB nTab = 0; nTab < nTableCount && !bFound; ++nTab)
240 if (m_aDocument.HasTabNotes(nTab))
245 nState |= HiddenInformation::NOTES;
253 m_aDocument.EnableIdle(
false);
256 OSL_ENSURE(m_pModificator ==
nullptr,
"The Modificator should not exist");
259 m_aDocument.SetImportingXML(
true );
260 m_aDocument.EnableExecuteLink(
false );
261 m_aDocument.EnableUndo(
false );
263 m_aDocument.SetInsertingFromOtherDoc(
true );
268 if (GetCreateMode() != SfxObjectCreateMode::ORGANIZER)
272 m_aDocument.SetInsertingFromOtherDoc(
false );
280 SCTAB nTabCount = m_aDocument.GetTableCount();
281 for (
SCTAB i = 0;
i < nTabCount; ++
i)
283 if (m_aDocument.IsLinked(
i ))
286 m_aDocument.GetName(
i, aName);
287 OUString aLinkTabName = m_aDocument.GetLinkTab(
i);
288 sal_Int32 nLinkTabNameLength = aLinkTabName.getLength();
289 sal_Int32 nNameLength = aName.getLength();
290 if (nLinkTabNameLength < nNameLength)
295 if ( *pNameBuffer ==
'\'' &&
298 OUStringBuffer aDocURLBuffer;
301 while ( bQuote && *pNameBuffer )
303 if ( *pNameBuffer ==
'\'' && *(pNameBuffer-1) !=
'\\' )
305 else if( *pNameBuffer !=
'\\' || *(pNameBuffer+1) !=
'\'' )
306 aDocURLBuffer.append(*pNameBuffer);
312 sal_Int32
nIndex = nNameLength - nLinkTabNameLength;
313 INetURLObject aINetURLObject(aDocURLBuffer.makeStringAndClear());
314 if(aName.match( aLinkTabName, nIndex) &&
315 (aName[nIndex - 1] ==
'#') &&
316 !aINetURLObject.HasError())
319 m_aDocument.RenameTab(
i, aName,
true);
336 size_t nDPCount = pDPCollection->
GetCount();
337 for (
size_t nDP=0; nDP<nDPCount; ++nDP)
340 if (rDPObj.
GetName().isEmpty())
347 m_aDocument.SetInsertingFromOtherDoc(
false );
349 m_aDocument.SetImportingXML(
false );
350 m_aDocument.EnableExecuteLink(
true );
351 m_aDocument.EnableUndo(
true );
362 m_pModificator.reset();
363 m_aDocument.SetHardRecalcState(eRecalcState);
367 OSL_FAIL(
"The Modificator should exist");
370 m_aDocument.EnableIdle(
true);
375 class LoadMediumGuard
381 mpDoc->SetLoadingMedium(
true);
386 mpDoc->SetLoadingMedium(
false);
427 MessageWithCheck(
weld::Window *pParent,
const OUString& rUIFile,
const OString& rDialogId)
428 : MessageDialogController(pParent, rUIFile, rDialogId,
"ask")
429 , m_xWarningOnBox(m_xBuilder->weld_check_button(
"ask"))
432 bool get_active()
const {
return m_xWarningOnBox->get_active(); }
433 void hide_ask()
const { m_xWarningOnBox->set_visible(
false); };
437 class VBAScriptListener :
public ::cppu::WeakImplHelper< css::script::vba::XVBAScriptListener >
442 VBAScriptListener(
ScDocShell* pDocSh) : m_pDocSh(pDocSh)
447 virtual void SAL_CALL notifyVBAScriptEvent( const ::css::script::vba::VBAScriptEvent& aEvent )
override
449 if (aEvent.Identifier == script::vba::VBAScriptEventId::SCRIPT_STOPPED &&
452 m_pDocSh->
SetClipData(uno::Reference<datatransfer::XTransferable2>());
457 virtual void SAL_CALL disposing( const ::css::lang::EventObject& )
override
466 LoadMediumGuard aLoadGuard(&m_aDocument);
478 m_aDocument.LockAdjustHeight();
479 if (GetCreateMode() == SfxObjectCreateMode::ORGANIZER)
492 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(GetModel(), uno::UNO_QUERY_THROW);
493 uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
497 static_cast<ScRecalcOptions>(officecfg::Office::Calc::Formula::Load::ODFRecalcMode::get(xContext));
499 bool bHardRecalc =
false;
503 if (m_aDocument.IsUserInteractionEnabled() && xDocProps->getGenerator().indexOf(sProductName) == -1)
507 MessageWithCheck aQueryBox(GetActiveDialogParent(),
508 "modules/scalc/ui/recalcquerydialog.ui",
"RecalcQueryDialog");
509 aQueryBox.set_primary_text(
ScResId(STR_QUERY_FORMULA_RECALC_ONLOAD_ODS));
510 aQueryBox.set_default_response(
RET_YES);
512 if ( officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::isReadOnly() )
513 aQueryBox.hide_ask();
515 bHardRecalc = aQueryBox.run() ==
RET_YES;
517 if (aQueryBox.get_active())
521 officecfg::Office::Calc::Formula::Load::ODFRecalcMode::set(sal_Int32(0), batch);
526 SC_MOD()->SetFormulaOptions(aOpt);
543 AfterXMLLoading(bRet);
545 m_aDocument.UnlockAdjustHeight();
551 m_aDocument.EnableIdle(
false);
555 if (GetCreateMode() != SfxObjectCreateMode::ORGANIZER)
556 bRet = aImport.
Export(
false);
558 bRet = aImport.
Export(
true);
560 m_aDocument.EnableIdle(
true);
567 LoadMediumGuard aLoadGuard(&m_aDocument);
576 if (IsOwnStorageFormat(rMedium))
578 if (m_aDocument.GetDrawLayer())
579 m_aDocument.GetDrawLayer()->SetAnchoredTextOverflowLegacy(
true);
582 GetUndoManager()->Clear();
589 const SfxUInt16Item* pUpdateDocItem = SfxItemSet::GetItem<SfxUInt16Item>(rMedium.
GetItemSet(), SID_UPDATEDOCMODE,
false);
590 m_nCanUpdate = pUpdateDocItem ? pUpdateDocItem->
GetValue() : css::document::UpdateDocMode::NO_UPDATE;
606 m_aDocument.MakeTable(0);
607 m_aDocument.GetStyleSheetPool()->CreateStandardStyles();
608 m_aDocument.UpdStlShtPtrsFrmNms();
614 OUString
aURL(
"$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER
"/calc/styles.xml");
615 rtl::Bootstrap::expandMacros(aURL);
618 osl::FileBase::getSystemPathFromFileURL(aURL, aPath);
625 m_aDocument.GetStyleSheetPool()->setAllParaStandard();
629 bRet = LoadXML( &rMedium,
nullptr );
644 m_aDocument.InvalidateTableArea();
658 uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = m_aDocument.GetVbaEventProcessor();
659 if ( xVbaEvents.is() )
try
661 uno::Sequence< uno::Any > aArgs( 1 );
662 aArgs[0] <<= pScHint->
GetTab1();
663 xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKBOOK_NEWSHEET, aArgs );
665 catch( uno::Exception& )
671 if (
auto pStyleSheetHint = dynamic_cast<const SfxStyleSheetHint*>(&rHint) )
672 NotifyStyle( *pStyleSheetHint );
673 else if (
auto pStlHint = dynamic_cast<const ScAutoStyleHint*>(&rHint) )
681 const ScRange& aRange = pStlHint->GetRange();
682 const OUString& aName1 = pStlHint->GetStyle1();
683 const OUString& aName2 = pStlHint->GetStyle2();
684 sal_uInt32 nTimeout = pStlHint->GetTimeout();
686 if (!m_pAutoStyleList)
688 m_pAutoStyleList->AddInitial( aRange, aName1, nTimeout, aName2 );
690 else if (
auto pEventHint = dynamic_cast<const SfxEventHint*>(&rHint) )
696 case SfxEventHintId::LoadFinished:
698 #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
700 if ( HasSharedXMLFlagSet() && !
SC_MOD()->IsInSharedDocLoading() && !
IsReadOnly() )
702 if ( SwitchToShared(
true,
false ) )
721 case SfxEventHintId::ViewCreated:
723 #if HAVE_FEATURE_SCRIPTING
724 uno::Reference<script::vba::XVBACompatibility> xVBACompat(GetBasicContainer(), uno::UNO_QUERY);
725 if ( !m_xVBAListener.is() && xVBACompat.is() )
727 m_xVBAListener.set(
new VBAScriptListener(
this));
728 xVBACompat->addVBAScriptListener(m_xVBAListener);
732 #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
733 if ( IsDocShared() && !
SC_MOD()->IsInSharedDocLoading() )
739 "modules/scalc/ui/sharedwarningdialog.ui",
"SharedWarningDialog");
742 bool bChecked = aWarningBox.get_active();
746 SC_MOD()->SetAppOptions( aAppOptions );
753 uno::Reference< uno::XComponentContext > xContext(
755 uno::Reference< lang::XMultiServiceFactory > xServiceManager(
756 xContext->getServiceManager(),
757 uno::UNO_QUERY_THROW );
758 uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xServiceManager, uno::UNO_QUERY_THROW );
759 uno::Reference< container::XEnumeration> xEnum = xEnumAccess->createContentEnumeration(
760 "com.sun.star.sheet.SpreadsheetDocumentJob" );
763 while ( xEnum->hasMoreElements() )
765 uno::Any aAny = xEnum->nextElement();
766 uno::Reference< lang::XSingleComponentFactory >
xFactory;
770 uno::Reference< task::XJob > xJob( xFactory->createInstanceWithContext( xContext ), uno::UNO_QUERY_THROW );
772 SfxViewShell* pViewShell = ( pViewData ? pViewData->GetViewShell() : nullptr );
776 uno::Reference< sheet::XSpreadsheetView > xSpreadsheetView( xController, uno::UNO_QUERY_THROW );
777 uno::Sequence< beans::NamedValue > aArgsForJob { {
"SpreadsheetView",
uno::makeAny( xSpreadsheetView ) } };
778 xJob->execute( aArgsForJob );
783 catch ( uno::Exception & )
788 case SfxEventHintId::SaveDoc:
790 #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
791 if ( IsDocShared() && !
SC_MOD()->IsInSharedDocSaving() )
793 bool bSuccess =
false;
798 uno::Reference< frame::XModel >
xModel;
802 xModel.set( LoadSharedDocument(), uno::UNO_SET_THROW );
803 uno::Reference< util::XCloseable > xCloseable( xModel, uno::UNO_QUERY_THROW );
806 bool bShared =
false;
807 ScModelObj* pDocObj = comphelper::getUnoTunnelImplementation<ScModelObj>( xModel );
809 if ( pSharedDocShell )
815 bool bOwnEntry =
false;
816 bool bEntriesNotAccessible =
false;
822 catch ( uno::Exception& )
824 bEntriesNotAccessible =
true;
827 if ( bShared && bOwnEntry )
829 uno::Reference< frame::XStorable > xStorable( xModel, uno::UNO_QUERY_THROW );
831 if ( xStorable->isReadonly() )
833 xCloseable->close(
true );
835 OUString aUserName(
ScResId( STR_UNKNOWN_USER ) );
836 bool bNoLockAccess =
false;
841 if ( !aData[LockFileComponent::OOOUSERNAME].isEmpty() )
843 aUserName = aData[LockFileComponent::OOOUSERNAME];
845 else if ( !aData[LockFileComponent::SYSUSERNAME].isEmpty() )
847 aUserName = aData[LockFileComponent::SYSUSERNAME];
850 catch ( uno::Exception& )
852 bNoLockAccess =
true;
862 OUString aMessage(
ScResId( STR_FILE_LOCKED_SAVE_LATER ) );
863 aMessage = aMessage.replaceFirst(
"%1", aUserName );
866 VclMessageType::Warning, VclButtonsType::NONE,
880 bool bSaveToShared =
false;
881 if ( pSharedDocShell )
883 bSaveToShared = MergeSharedDocument( pSharedDocShell );
887 xCloseable->close(
true );
894 bool bChangedViewSettings =
false;
896 if ( pChangeViewSet && pChangeViewSet->
ShowChanges() )
900 m_aDocument.SetChangeViewSettings( *pChangeViewSet );
901 bChangedViewSettings =
true;
904 uno::Reference< frame::XStorable > xStor( GetModel(), uno::UNO_QUERY_THROW );
906 uno::Sequence< beans::PropertyValue > aValues(1);
907 aValues[0].Name =
"FilterName";
908 aValues[0].Value <<= GetMedium()->GetFilter()->GetFilterName();
910 const SfxStringItem* pPasswordItem = SfxItemSet::GetItem<SfxStringItem>(GetMedium()->GetItemSet(), SID_PASSWORD,
false);
911 if ( pPasswordItem && !pPasswordItem->
GetValue().isEmpty() )
913 aValues.realloc( 2 );
914 aValues[1].Name =
"Password";
915 aValues[1].Value <<= pPasswordItem->
GetValue();
918 SC_MOD()->SetInSharedDocSaving(
true );
919 xStor->storeToURL( GetSharedFileURL(), aValues );
920 SC_MOD()->SetInSharedDocSaving(
false );
922 if ( bChangedViewSettings )
926 m_aDocument.SetChangeViewSettings( *pChangeViewSet );
931 GetUndoManager()->Clear();
936 xCloseable->close(
true );
938 if ( bEntriesNotAccessible )
946 VclMessageType::Warning, VclButtonsType::Ok,
947 ScResId(STR_DOC_NOLONGERSHARED)));
958 catch ( uno::Exception& )
961 SC_MOD()->SetInSharedDocSaving(
false );
965 uno::Reference< util::XCloseable > xClose( xModel, uno::UNO_QUERY_THROW );
966 xClose->close(
true );
968 catch ( uno::Exception& )
979 if (m_pSheetSaveData)
980 m_pSheetSaveData->SetInSupportedSave(
true);
983 case SfxEventHintId::SaveAsDoc:
985 if ( GetDocument().GetExternalRefManager()->containsUnsavedReferences() )
988 VclMessageType::Warning, VclButtonsType::YesNo,
989 ScResId(STR_UNSAVED_EXT_REF)));
990 if (
RET_NO == xWarn->run())
997 case SfxEventHintId::SaveToDoc:
1001 if (m_pSheetSaveData)
1002 m_pSheetSaveData->SetInSupportedSave(
true);
1004 case SfxEventHintId::SaveDocDone:
1005 case SfxEventHintId::SaveAsDocDone:
1008 UseSheetSaveEntries();
1011 case SfxEventHintId::SaveToDocDone:
1013 if (m_pSheetSaveData)
1014 m_pSheetSaveData->SetInSupportedSave(
false);
1022 else if (rHint.
GetId() == SfxHintId::TitleChanged)
1028 else if (rHint.
GetId() == SfxHintId::Deinitializing)
1031 #if HAVE_FEATURE_SCRIPTING
1032 uno::Reference<script::vba::XVBACompatibility> xVBACompat(GetBasicContainer(), uno::UNO_QUERY);
1033 if (m_xVBAListener.is() && xVBACompat.is())
1035 xVBACompat->removeVBAScriptListener(m_xVBAListener);
1039 if (m_aDocument.IsClipboardSource())
1058 case SfxEventHintId::CreateDoc:
1061 aWorkbook <<= mxAutomationWorkbookObject;
1062 uno::Sequence< uno::Any > aArgs(1);
1063 aArgs[0] = aWorkbook;
1064 SC_MOD()->CallAutomationApplicationEventSinks(
"NewWorkbook", aArgs );
1067 case SfxEventHintId::OpenDoc:
1070 aWorkbook <<= mxAutomationWorkbookObject;
1071 uno::Sequence< uno::Any > aArgs(1);
1072 aArgs[0] = aWorkbook;
1073 SC_MOD()->CallAutomationApplicationEventSinks(
"WorkbookOpen", aArgs );
1084 LoadMediumGuard aLoadGuard(&m_aDocument);
1093 const SfxUInt16Item* pUpdateDocItem = SfxItemSet::GetItem<SfxUInt16Item>(rMedium.
GetItemSet(), SID_UPDATEDOCMODE,
false);
1094 m_nCanUpdate = pUpdateDocItem ? pUpdateDocItem->
GetValue() : css::document::UpdateDocMode::NO_UPDATE;
1099 bRet = LoadXML( &rMedium,
nullptr );
1109 OUStringBuffer
aBuf;
1110 std::vector< OUString > aTokens;
1111 sal_Int32
n = rOption.getLength();
1113 for (sal_Int32
i = 0;
i < n; ++
i)
1118 if (!aBuf.isEmpty())
1119 aTokens.push_back( aBuf.makeStringAndClear() );
1125 if (!aBuf.isEmpty())
1126 aTokens.push_back( aBuf.makeStringAndClear() );
1129 rDateConvert =
false;
1131 if (!aTokens.empty())
1132 rLang = static_cast<LanguageType>(aTokens[0].
toInt32());
1133 if (aTokens.size() > 1)
1134 rDateConvert = static_cast<bool>(aTokens[1].
toInt32());
1139 LoadMediumGuard aLoadGuard(&m_aDocument);
1146 GetUndoManager()->Clear();
1149 bool bSetColWidths =
false;
1150 bool bSetSimpleTextColWidths =
false;
1151 std::map<SCCOL, ScColWidthParam> aColWidthParam;
1154 bool bSetRowHeights =
false;
1156 vector<ScDocRowHeightUpdater::TabRanges> aRecalcRowRangesArray;
1162 const SfxUInt16Item* pUpdateDocItem = SfxItemSet::GetItem<SfxUInt16Item>(rMedium.
GetItemSet(), SID_UPDATEDOCMODE,
false);
1163 m_nCanUpdate = pUpdateDocItem ? pUpdateDocItem->
GetValue() : css::document::UpdateDocMode::NO_UPDATE;
1165 std::shared_ptr<const SfxFilter> pFilter = rMedium.
GetFilter();
1168 OUString aFltName = pFilter->GetFilterName();
1170 bool bCalc3 = aFltName ==
"StarCalc 3.0";
1171 bool bCalc4 = aFltName ==
"StarCalc 4.0";
1172 if (!bCalc3 && !bCalc4)
1173 m_aDocument.SetInsertingFromOtherDoc(
true );
1176 bRet = LoadXML( &rMedium,
nullptr );
1182 if ( pSet && SfxItemState::SET ==
1183 pSet->
GetItemState( SID_FILE_FILTEROPTIONS,
true, &pItem ) )
1188 if (sItStr.isEmpty())
1207 bSetColWidths =
true;
1208 bSetRowHeights =
true;
1227 m_aDocument.UpdateFontCharSet();
1228 if ( m_aDocument.IsChartListenerCollectionNeedsUpdate() )
1229 m_aDocument.UpdateChartListenerCollection();
1232 m_aDocument.EnsureGraphicNames();
1248 else if (aFltName ==
"Gnumeric Spreadsheet")
1256 else if (aFltName ==
"MS Excel 2003 XML Orcus")
1269 bool bOptInit =
false;
1271 if ( pSet && SfxItemState::SET ==
1272 pSet->
GetItemState( SID_FILE_FILTEROPTIONS,
true, &pItem ) )
1283 aOptions.
SetCharSet( RTL_TEXTENCODING_MS_1252 );
1289 bool bOverflowRow, bOverflowCol, bOverflowCell;
1290 bOverflowRow = bOverflowCol = bOverflowCell =
false;
1301 pInStream->
Seek( 0 );
1304 m_aDocument.StartAllListeners();
1306 m_aDocument.SetAllFormulasDirty(aCxt);
1326 OSL_FAIL(
"No Stream" );
1335 else if (!
GetError() && (bOverflowRow || bOverflowCol || bOverflowCell))
1343 bSetColWidths =
true;
1344 bSetSimpleTextColWidths =
true;
1351 if ( pSet && SfxItemState::SET ==
1352 pSet->
GetItemState( SID_FILE_FILTEROPTIONS,
true, &pItem ) )
1357 if (sItStr.isEmpty())
1368 aRecalcRowRangesArray.push_back(aRecalcRanges);
1380 bSetColWidths =
true;
1381 bSetSimpleTextColWidths =
true;
1392 if ( pSet && SfxItemState::SET ==
1393 pSet->
GetItemState( SID_FILE_FILTEROPTIONS,
true, &pItem ) )
1398 if (sItStr.isEmpty())
1419 bSetColWidths =
true;
1420 bSetSimpleTextColWidths =
true;
1421 bSetRowHeights =
true;
1426 bool bOverflowRow, bOverflowCol, bOverflowCell;
1427 bOverflowRow = bOverflowCol = bOverflowCell =
false;
1435 pInStream->
Seek( 0 );
1438 m_aDocument.StartAllListeners();
1440 m_aDocument.SetAllFormulasDirty(aCxt);
1448 OSL_FAIL(
"No Stream" );
1454 else if (!
GetError() && (bOverflowRow || bOverflowCol || bOverflowCell))
1462 bSetColWidths =
true;
1463 bSetSimpleTextColWidths =
true;
1464 bSetRowHeights =
true;
1482 bSetRowHeights =
true;
1492 pInStream->
Seek( 0 );
1505 m_aDocument.StartAllListeners();
1507 m_aDocument.SetAllFormulasDirty(aCxt);
1508 bSetColWidths =
true;
1509 bSetRowHeights =
true;
1513 OSL_FAIL(
"No Stream" );
1530 bool bDateConvert =
false;
1533 if ( pSet && SfxItemState::SET ==
1534 pSet->
GetItemState( SID_FILE_FILTEROPTIONS,
true, &pItem ) )
1540 pInStream->
Seek( 0 );
1546 GetOutputFactor(), !bWebQuery, &aNumFormatter, bDateConvert );
1557 m_aDocument.StartAllListeners();
1560 m_aDocument.SetAllFormulasDirty(aCxt);
1564 OSL_FAIL(
"No Stream" );
1575 SAL_WARN(
"sc.filter",
"No match for filter '" << aFltName <<
"' in ConvertFrom");
1581 m_aDocument.SetInsertingFromOtherDoc(
false );
1585 OSL_FAIL(
"No Filter in ConvertFrom");
1590 if ( bRet && (bSetColWidths || bSetRowHeights) )
1597 SCTAB nTabCount = m_aDocument.GetTableCount();
1598 for (
SCTAB nTab=0; nTab<nTabCount; nTab++)
1602 m_aDocument.GetCellArea( nTab, nEndCol, nEndRow );
1605 ScMarkData aMark(m_aDocument.GetSheetLimits());
1607 aMark.MarkToMulti();
1610 if ( bSetColWidths )
1612 for (
SCCOL nCol=0; nCol <= nEndCol; nCol++ )
1614 if (!bSetSimpleTextColWidths)
1615 aColWidthParam[nCol].mbSimpleText =
false;
1617 sal_uInt16 nWidth = m_aDocument.GetOptimalColWidth(
1618 nCol, nTab, pVirtDev, nPPTX, nPPTY, aZoom, aZoom,
false, &aMark,
1619 &aColWidthParam[nCol] );
1620 m_aDocument.SetColWidth( nCol, nTab,
1633 else if (!aRecalcRowRangesArray.empty())
1645 m_aDocument.InvalidateTableArea();
1654 std::shared_ptr<const SfxFilter> pFilter = rMed.
GetFilter();
1658 if (pFilter->GetProviderName() ==
"orcus")
1664 const OUString& rFilterName = pFilter->GetName();
1665 if (rFilterName ==
"gnumeric")
1670 else if (rFilterName ==
"csv")
1672 if (!pOrcus->
importCSV(m_aDocument, rMed))
1675 else if (rFilterName ==
"xlsx")
1680 else if (rFilterName ==
"ods")
1682 if (!pOrcus->
importODS(m_aDocument, rMed))
1694 : mrDocShell( rDocShell)
1719 if (mrDocShell.m_aDocument.HasExternalRefManager())
1738 if (
auto pSysWin = pFrame1->GetWindow().GetSystemWindow())
1740 pSysWin->SetAccessibleName(OUString());
1755 void popFileName(OUString& rPath)
1757 if (!rPath.isEmpty())
1760 aURLObj.removeSegment();
1770 SC_MOD()->InputEnterHandler();
1779 aCurPath = pCurMedium->
GetName();
1780 popFileName(aCurPath);
1783 if (!aCurPath.isEmpty())
1786 OUString aNewPath = rMedium.
GetName();
1787 popFileName(aNewPath);
1789 if (!aRel.isEmpty())
1806 if (pViewShell && bNeedsRehash)
1820 bRet =
SaveXML( &rMedium,
nullptr );
1828 sal_Int32 lcl_ScDocShell_GetColWidthInChars( sal_uInt16 nWidth )
1836 return sal_Int32( f );
1839 void lcl_ScDocShell_GetFixedWidthString( OUString& rStr,
const ScDocument& rDoc,
1842 OUString aString = rStr;
1843 sal_Int32 nLen = lcl_ScDocShell_GetColWidthInChars(
1846 if ( nLen < aString.getLength() )
1848 OUStringBuffer aReplacement;
1850 aReplacement.append(
"###");
1852 aReplacement.append(aString);
1857 if ( nLen > aString.getLength() )
1859 if ( bValue && eHorJust == SvxCellHorJustify::Standard )
1860 eHorJust = SvxCellHorJustify::Right;
1861 sal_Int32 nBlanks = nLen - aString.getLength();
1864 case SvxCellHorJustify::Right:
1866 OUStringBuffer aTmp;
1868 aString = aTmp.append(aString).makeStringAndClear();
1871 case SvxCellHorJustify::Center:
1873 sal_Int32 nLeftPad = nBlanks / 2;
1874 OUStringBuffer aTmp;
1876 aTmp.append(aString);
1878 aString = aTmp.makeStringAndClear();
1883 OUStringBuffer aTmp(aString);
1885 aString = aTmp.makeStringAndClear();
1892 void lcl_ScDocShell_WriteEmptyFixedWidthString(
SvStream& rStream,
1896 lcl_ScDocShell_GetFixedWidthString( aString, rDoc, nTab, nCol,
false,
1897 SvxCellHorJustify::Standard );
1901 template<
typename StrT,
typename SepCharT>
1902 sal_Int32 getTextSepPos(
1903 const StrT& rStr,
const ScImportOptions& rAsciiOpt,
const SepCharT& rTextSep,
const SepCharT& rFieldSep,
bool& rNeedQuotes)
1907 sal_Int32
nPos = rStr.indexOf(rTextSep);
1909 (rStr.indexOf(rFieldSep) >= 0) ||
1910 (rStr.indexOf(
'\n') >= 0) ||
1911 (rStr.indexOf(
'\r') >= 0);
1915 template<
typename StrT,
typename StrBufT>
1916 void escapeTextSep(sal_Int32 nPos,
const StrT& rStrDelim, StrT& rStr)
1921 aBuf.insert(nPos, rStrDelim);
1922 rStr =
aBuf.makeStringAndClear();
1923 nPos = rStr.indexOf(rStrDelim, nPos+1+rStrDelim.getLength());
1933 rtl_TextEncoding eCharSet = rAsciiOpt.
eCharSet;
1942 OString aStrDelimEncoded;
1943 OUString aStrDelimDecoded;
1944 OString aDelimEncoded;
1945 OUString aDelimDecoded;
1946 bool bContextOrNotAsciiEncoding;
1947 if ( eCharSet == RTL_TEXTENCODING_UNICODE )
1950 bContextOrNotAsciiEncoding =
false;
1954 aStrDelimEncoded = OString(&cStrDelim, 1, eCharSet);
1955 aDelimEncoded = OString(&cDelim, 1, eCharSet);
1956 rtl_TextEncodingInfo aInfo;
1957 aInfo.StructSize =
sizeof(aInfo);
1958 if ( rtl_getTextEncodingInfo( eCharSet, &aInfo ) )
1960 bContextOrNotAsciiEncoding =
1961 (((aInfo.Flags & RTL_TEXTENCODING_INFO_CONTEXT) != 0) ||
1962 ((aInfo.Flags & RTL_TEXTENCODING_INFO_ASCII) == 0));
1963 if ( bContextOrNotAsciiEncoding )
1965 aStrDelimDecoded = OStringToOUString(aStrDelimEncoded, eCharSet);
1966 aDelimDecoded = OStringToOUString(aDelimEncoded, eCharSet);
1970 bContextOrNotAsciiEncoding =
false;
1973 SCCOL nStartCol = 0;
1974 SCROW nStartRow = 0;
1988 SCCOL nNextCol = nStartCol;
1989 SCROW nNextRow = nStartRow;
1997 while ( ( pCell = aIter.
GetNext( nCol, nRow ) ) !=
nullptr )
1999 bool bProgress =
false;
2000 if ( nNextRow < nRow )
2003 for ( nEmptyCol = nNextCol; nEmptyCol < nEndCol; nEmptyCol++ )
2006 lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
2008 else if ( cDelim != 0 )
2013 for ( nEmptyRow = nNextRow; nEmptyRow < nRow; nEmptyRow++ )
2015 for ( nEmptyCol = nStartCol; nEmptyCol < nEndCol; nEmptyCol++ )
2018 lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
2020 else if ( cDelim != 0 )
2025 for ( nEmptyCol = nStartCol; nEmptyCol < nCol; nEmptyCol++ )
2028 lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
2030 else if ( cDelim != 0 )
2035 else if ( nNextCol < nCol )
2037 for ( nEmptyCol = nNextCol; nEmptyCol < nCol; nEmptyCol++ )
2040 lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
2042 else if ( cDelim != 0 )
2046 if ( nCol == nEndCol )
2049 nNextCol = nStartCol;
2050 nNextRow = nRow + 1;
2053 nNextCol = nCol + 1;
2066 bool bForceQuotes =
false;
2077 if ( bShowFormulas )
2090 if ( bFixedWidth || bSaveAsShown )
2092 const Color* pDummy;
2094 bString = bSaveAsShown && rFormatter.
IsTextFormat( nFormat);
2099 bString = bForceQuotes = !bSaveNumberAsSuch;
2107 const Color* pDummy;
2120 const Color* pDummy;
2140 if ( bFixedWidth || bSaveAsShown )
2142 const Color* pDummy;
2144 bString = bSaveAsShown && rFormatter.
IsTextFormat( nFormat);
2149 bString = bForceQuotes = !bSaveNumberAsSuch;
2154 OSL_FAIL(
"ScDocShell::AsciiSave: unknown CellType" );
2163 lcl_ScDocShell_GetFixedWidthString( aString,
m_aDocument, nTab, nCol,
2164 !bString, eHorJust );
2169 OUString aUniString = aString;
2170 if (!bString && cStrDelim != 0 && !aUniString.isEmpty())
2173 bString = (c == cStrDelim || c ==
' ' ||
2174 aUniString.endsWith(
" ") ||
2175 aUniString.indexOf(cStrDelim) >= 0);
2176 if (!bString && cDelim != 0)
2177 bString = (aUniString.indexOf(cDelim) >= 0);
2181 if ( cStrDelim != 0 )
2183 if ( eCharSet == RTL_TEXTENCODING_UNICODE )
2185 bool bNeedQuotes =
false;
2186 sal_Int32 nPos = getTextSepPos(
2187 aUniString, rAsciiOpt, cStrDelim, cDelim, bNeedQuotes);
2189 escapeTextSep<OUString, OUStringBuffer>(
2190 nPos, OUString(cStrDelim), aUniString);
2192 if ( bNeedQuotes || bForceQuotes )
2195 if ( bNeedQuotes || bForceQuotes )
2214 if ( bContextOrNotAsciiEncoding )
2219 OUString aStrDec = OStringToOUString(aStrEnc, eCharSet);
2222 bool bNeedQuotes =
false;
2223 sal_Int32 nPos = getTextSepPos(
2224 aStrDec, rAsciiOpt, aStrDelimDecoded, aDelimDecoded, bNeedQuotes);
2226 escapeTextSep<OUString, OUStringBuffer>(
2227 nPos, aStrDelimDecoded, aStrDec);
2230 if ( bNeedQuotes || bForceQuotes )
2233 if ( bNeedQuotes || bForceQuotes )
2241 bool bNeedQuotes =
false;
2242 sal_Int32 nPos = getTextSepPos(
2243 aStrEnc, rAsciiOpt, aStrDelimEncoded, aDelimEncoded, bNeedQuotes);
2245 escapeTextSep<OString, OStringBuffer>(
2246 nPos, aStrDelimEncoded, aStrEnc);
2249 if ( bNeedQuotes || bForceQuotes )
2251 aStrDelimEncoded.getStr(), aStrDelimEncoded.getLength());
2252 rStream.
WriteBytes(aStrEnc.getStr(), aStrEnc.getLength());
2253 if ( bNeedQuotes || bForceQuotes )
2255 aStrDelimEncoded.getStr(), aStrDelimEncoded.getLength());
2266 if( nCol < nEndCol )
2279 if ( nNextRow <= nEndRow )
2281 for ( nEmptyCol = nNextCol; nEmptyCol < nEndCol; nEmptyCol++ )
2284 lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
2286 else if ( cDelim != 0 )
2292 for ( nEmptyRow = nNextRow; nEmptyRow <= nEndRow; nEmptyRow++ )
2294 for ( nEmptyCol = nStartCol; nEmptyCol < nEndCol; nEmptyCol++ )
2297 lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
2299 else if ( cDelim != 0 )
2306 rStream.
SetEndian( nOldNumberFormatInt );
2321 OSL_ENSURE( rMed.
GetFilter(),
"Filter == 0" );
2324 OUString aFltName = rMed.
GetFilter()->GetFilterName();
2329 OSL_FAIL(
"XML filter in ConvertFrom?!");
2330 bRet =
SaveXML( &rMed,
nullptr );
2338 bool bDoSave =
true;
2347 pViewShell->GetViewData().WriteExtOptions( *pExtDocOpt );
2352 if( (rMed.
GetFilter()->GetFilterFlags() & SfxFilterFlags::ENCRYPTION) == SfxFilterFlags::NONE )
2356 if( pItemSet && pItemSet->
GetItemState( SID_PASSWORD,
true, &pItem ) == SfxItemState::SET )
2368 bDoSave = !bNeedRetypePassDlg || pViewShell->ExecuteRetypePassDlg(
PASSHASH_XL );
2399 if ( pSet && SfxItemState::SET ==
2400 pSet->
GetItemState( SID_FILE_FILTEROPTIONS,
true, &pItem ) )
2405 if ( sItStr.isEmpty() )
2429 if ( pSet && SfxItemState::SET ==
2430 pSet->
GetItemState( SID_FILE_FILTEROPTIONS,
true, &pItem ) )
2435 if (sCharSet.isEmpty())
2446 bool bHasMemo =
false;
2482 if ( bRet && !
MoveFile( aTmpFile, aDbtFile ) )
2503 if ( pSet && SfxItemState::SET ==
2504 pSet->
GetItemState( SID_FILE_FILTEROPTIONS,
true, &pItem ) )
2509 if (sItStr.isEmpty())
2537 ScRange aRange( 0,0,0, nEndCol,nEndRow,0 );
2551 OUString sFilterOptions;
2553 if (pSet->
GetItemState(SID_FILE_FILTEROPTIONS,
true, &pItem) == SfxItemState::SET)
2554 sFilterOptions = static_cast<const SfxStringItem*>(pItem)->GetValue();
2566 DialogMask::ButtonsOk | DialogMask::MessageInfo));
2583 Broadcast(
SfxHint( SfxHintId::ScDocSaved ) );
2593 sal_Int32 nVbaEventId = VBAEventId::NO_EVENT;
2594 uno::Sequence< uno::Any > aArgs;
2599 nVbaEventId = VBAEventId::WORKBOOK_BEFORESAVE;
2601 aArgs[ 0 ] <<= (nSlotId == SID_SAVEASDOC);
2604 case SID_PRINTDOCDIRECT:
2605 nVbaEventId = VBAEventId::WORKBOOK_BEFOREPRINT;
2609 bool bSlotExecutable =
true;
2610 if( nVbaEventId != VBAEventId::NO_EVENT )
try
2613 xEventProcessor->processVbaEvent( nVbaEventId, aArgs );
2615 catch( util::VetoException& )
2617 bSlotExecutable =
false;
2619 catch( uno::Exception& )
2622 return bSlotExecutable;
2627 if(
SC_MOD()->GetCurRefDlgId()>0)
2634 if(pViewSh!=
nullptr)
2657 uno::Sequence< uno::Any > aArgs;
2658 xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKBOOK_BEFORECLOSE, aArgs );
2660 catch( util::VetoException& )
2665 catch( uno::Exception& )
2731 return std::make_unique<ScDocFuncDirect>( *this );
2801 OSL_FAIL(
"The Modificator should not exist");
2816 Broadcast(
SfxHint( SfxHintId::DocChanged ) );
2891 if (bUpdate && pBindings)
2912 SC_MOD()->AnythingChanged();
2930 static_cast<sal_uInt16>(
ScPrintFunc(
this, pPrinter,
i ).GetTotalPages()) );
2935 std::shared_ptr<SfxDocumentInfoDialog> xDlg = std::make_shared<SfxDocumentInfoDialog>(pParent, rSet);
2939 if( pDocSh ==
this )
2943 OSL_ENSURE(ScDocStatPageCreate,
"Tabpage create fail!");
2944 xDlg->AddFontTabPage();
2945 xDlg->AddTabPage(
"calcstats",
ScResId(STR_DOC_STAT), ScDocStatPageCreate);
2982 void removeKeysIfExists(
const Reference<ui::XAcceleratorConfiguration>& xScAccel,
const vector<const awt::KeyEvent*>& rKeys)
2984 for (
const awt::KeyEvent* p : rKeys)
2991 xScAccel->removeKeyEvent(*p);
2993 catch (
const container::NoSuchElementException&) {}
3007 Reference<XModuleUIConfigurationManagerSupplier> xModuleCfgSupplier(
3008 theModuleUIConfigurationManagerSupplier::get(xContext) );
3011 Reference<XUIConfigurationManager> xConfigMgr =
3012 xModuleCfgSupplier->getUIConfigurationManager(
3013 "com.sun.star.sheet.SpreadsheetDocument");
3015 if (!xConfigMgr.is())
3019 Reference<XAcceleratorConfiguration> xScAccel = xConfigMgr->getShortCutManager();
3024 vector<const awt::KeyEvent*> aKeys;
3028 awt::KeyEvent aBackspace;
3029 aBackspace.KeyCode = awt::Key::BACKSPACE;
3030 aBackspace.Modifiers = 0;
3031 aKeys.push_back(&aBackspace);
3034 awt::KeyEvent aDelete;
3035 aDelete.KeyCode = awt::Key::DELETE;
3036 aDelete.Modifiers = 0;
3037 aKeys.push_back(&aDelete);
3040 awt::KeyEvent aCtrlD;
3041 aCtrlD.KeyCode = awt::Key::D;
3042 aCtrlD.Modifiers = awt::KeyModifier::MOD1;
3043 aKeys.push_back(&aCtrlD);
3046 awt::KeyEvent aAltDown;
3047 aAltDown.KeyCode = awt::Key::DOWN;
3048 aAltDown.Modifiers = awt::KeyModifier::MOD2;
3049 aKeys.push_back(&aAltDown);
3052 awt::KeyEvent aCtrlSpace;
3053 aCtrlSpace.KeyCode = awt::Key::SPACE;
3054 aCtrlSpace.Modifiers = awt::KeyModifier::MOD1;
3055 aKeys.push_back(&aCtrlSpace);
3058 awt::KeyEvent aCtrlShiftSpace;
3059 aCtrlShiftSpace.KeyCode = awt::Key::SPACE;
3060 aCtrlShiftSpace.Modifiers = awt::KeyModifier::MOD1 | awt::KeyModifier::SHIFT;
3061 aKeys.push_back(&aCtrlShiftSpace);
3065 aF4.KeyCode = awt::Key::F4;
3067 aKeys.push_back(&aF4);
3070 awt::KeyEvent aCtrlShiftF4;
3071 aCtrlShiftF4.KeyCode = awt::Key::F4;
3072 aCtrlShiftF4.Modifiers = awt::KeyModifier::MOD1 | awt::KeyModifier::SHIFT;
3073 aKeys.push_back(&aCtrlShiftF4);
3076 awt::KeyEvent aShiftF4;
3077 aShiftF4.KeyCode = awt::Key::F4;
3078 aShiftF4.Modifiers = awt::KeyModifier::SHIFT;
3079 aKeys.push_back(&aShiftF4);
3083 removeKeysIfExists(xScAccel, aKeys);
3089 xScAccel->setKeyEvent(aDelete,
".uno:ClearContents");
3090 xScAccel->setKeyEvent(aBackspace,
".uno:Delete");
3091 xScAccel->setKeyEvent(aCtrlD,
".uno:FillDown");
3092 xScAccel->setKeyEvent(aAltDown,
".uno:DataSelect");
3093 xScAccel->setKeyEvent(aCtrlSpace,
".uno:SelectColumn");
3094 xScAccel->setKeyEvent(aCtrlShiftSpace,
".uno:SelectAll");
3095 xScAccel->setKeyEvent(aF4,
".uno:ToggleRelative");
3096 xScAccel->setKeyEvent(aCtrlShiftF4,
".uno:ViewDataSourceBrowser");
3099 xScAccel->setKeyEvent(aDelete,
".uno:Delete");
3100 xScAccel->setKeyEvent(aBackspace,
".uno:ClearContents");
3101 xScAccel->setKeyEvent(aCtrlD,
".uno:DataSelect");
3102 xScAccel->setKeyEvent(aCtrlShiftSpace,
".uno:SelectColumn");
3103 xScAccel->setKeyEvent(aF4,
".uno:ViewDataSourceBrowser");
3104 xScAccel->setKeyEvent(aShiftF4,
".uno:ToggleRelative");
3120 bool bHasEntries =
false;
3123 for (nTab = 0; nTab < nTabCount; ++nTab)
3131 for (nTab = 0; nTab < nTabCount; ++nTab)
3182 return pChangeTrack !=
nullptr;
3229 if (!rNewPassword.isEmpty())
3234 css::uno::Sequence< sal_Int8 > aProtectionHash;
3240 pChangeTrack->
SetProtection( css::uno::Sequence< sal_Int8 >() );
3285 return aImpEx.
ImportStream(rStream, OUString(), SotClipboardFormatId::SYLK);
ScMarkData & GetMarkData()
sal_Unicode nFieldSepCode
Data stream data needs to be post-processed because it requires ScDocShell instance which is not avai...
SfxViewFrame * GetViewFrame() const
#define LINK(Instance, Class, Member)
virtual void SetVisArea(const tools::Rectangle &rVisArea)
void EnableIdle(bool bDo)
OUString GetText(LineEnd eEnd=LINEEND_LF) const
bool HasExternalRefManager() const
virtual HiddenInformation GetHiddenInformationState(HiddenInformation nStates) override
static OUString GetOwnFilterName()
std::size_t write_uInt16s_FromOUString(SvStream &rStrm, const OUString &rStr, std::size_t nUnits)
SC_DLLPUBLIC ScDBCollection * GetDBCollection() const
OUString getString() const
ScDocShell * GetDocShell() const
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
void SetExtOptions(const ScAsciiOptions &rOpt)
SfxPrinter * GetPrinter(bool bCreateIfNotExist=true)
const sc::ImportPostProcessData & GetImportPostProcessData() const
ScRefCellValue * GetNext(SCCOL &rCol, SCROW &rRow)
#define SFX_IMPL_INTERFACE(Class, SuperClass)
virtual bool DoSaveCompleted(SfxMedium *pNewStor=nullptr, bool bRegisterRecent=true)
bool IsInInterpreter() const
SC_DLLPUBLIC size_t GetCount() const
Collection of orcus filter wrappers.
#define SCWARN_EXPORT_NONCONVERTIBLE_CHARS
std::unique_ptr< ScDBData > m_pOldAutoDBRange
std::unique_ptr< ScRefreshTimerControl > const & GetRefreshTimerControlAddress() const
SC_DLLPUBLIC void SetChangeViewSettings(const ScChangeViewSettings &rNew)
virtual bool Load(SfxMedium &rMedium)
bool HasSharedXMLFlagSet() const
void RegisterAutomationWorkbookObject(css::uno::Reference< ooo::vba::excel::XWorkbook > const &xWorkbook)
SfxObjectShell * GetObjectShell() const
ScFormatSaveData * GetFormatSaveData()
const css::uno::Reference< css::script::vba::XVBAEventProcessor > & GetVbaEventProcessor() const
static weld::Window * GetActiveDialogParent()
SAL_DLLPUBLIC_EXPORT bool TestImportSLK(SvStream &rStream)
SfxBindings * GetViewBindings()
OUString GetStandardText(StandardButtonType eButton)
double m_nPrtToScreenFactor
bool Import(ImportFlags nMode, ErrCode &rError)
void SetProtection(const css::uno::Sequence< sal_Int8 > &rPass)
static vcl::Window * GetDefDialogParent()
virtual void SetModified(bool bModified=true)
ScDetOpList * GetDetOpList() const
css::uno::Reference< css::datatransfer::XTransferable2 > const & GetClipData() const
const OUString & GetName() const
Do things that need to be done before saving to our own format and necessary clean ups in dtor...
static OUString GetAsciiFilterName()
sal_Int32 toInt32(OUString const &rStr)
virtual std::shared_ptr< SfxDocumentInfoDialog > CreateDocumentInfoDialog(weld::Window *pParent, const SfxItemSet &rSet) override
void SetStateOnPercent(sal_uLong nVal)
void setAllCacheTableReferencedStati(bool bReferenced)
ScDocShell(const ScDocShell &rDocShell)=delete
virtual bool importODS(ScDocument &rDoc, SfxMedium &rMedium) const =0
normal calculation of dependencies
sal_uInt16 GetValue() const
static SVL_DLLPUBLIC void GetHashPassword(css::uno::Sequence< sal_Int8 > &rPassHash, const char *pPass, sal_uInt32 nLen)
const char pFilterEx5Temp[]
void SetDocumentModified()
Stores data imported from the file that need to be processed at the end of the import process...
constexpr OUStringLiteral pFilterDBase
#define SCWARN_IMPORT_RANGE_OVERFLOW
void SetSolverSaveData(std::unique_ptr< ScOptSolverSave > pData)
sal_uInt64 Seek(sal_uInt64 nPos)
bool ExecuteRetypePassDlg(ScPasswordHash eDesiredHash)
SAL_DLLPRIVATE void DoEnterHandler()
SC_DLLPUBLIC void GetNumberFormat(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt32 &rFormat) const
virtual bool SaveAs(SfxMedium &rMedium)
static OUString GetHtmlFilterName()
Extended options held by an ScDocument containing additional settings for filters.
virtual std::set< Color > GetDocColors() override
static SfxObjectShell * Current()
bool m_bAreasChangedNeedBroadcast
This is very similar to ScCellValue, except that it references the original value instead of copying ...
constexpr TypedWhichId< ScProtectionAttr > ATTR_PROTECTION(149)
const char pFilterQPro6[]
static OUString GetCharsetString(rtl_TextEncoding eVal)
void Invalidate(sal_uInt16 nId)
sc::DocumentLinkManager & GetDocLinkManager()
SC_DLLPUBLIC SfxUndoManager * GetUndoManager()
virtual bool importODS_Styles(ScDocument &rDoc, OUString &aFileName) const =0
Used to import just the styles from an xml file.
bool IsInPrepareClose() const
SVL_DLLPUBLIC OUString simpleNormalizedMakeRelative(OUString const &baseUriReference, OUString const &uriReference)
static OUString GetWebQueryFilterName()
bool ImportStream(SvStream &, const OUString &rBaseURL, SotClipboardFormatId)
~PrepareSaveGuard() COVERITY_NOEXCEPT_FALSE
~ScDocShellModificator() COVERITY_NOEXCEPT_FALSE
virtual bool ConvertTo(SfxMedium &rMedium) override
SfxApplication * SfxGetpApp()
virtual bool HasChangeRecordProtection() const override
const char pFilterEx95Temp[]
PrepareSaveGuard(ScDocShell &rDocShell)
constexpr OUStringLiteral pFilterHtmlWebQ
void InvalidateTableArea()
virtual SfxUndoManager * GetUndoManager() override
OUString CreateNewName() const
Create a new name that's not yet used by any existing data pilot objects.
virtual bool PrepareClose(bool bUI=true)
void SetCharSet(rtl_TextEncoding eNew)
weld::Window * GetFrameWeld() const
SC_DLLPUBLIC void SetImportingXML(bool bVal)
constexpr OUStringLiteral pFilterHtml
void SetRefreshOnEmptyLine(bool bVal)
Reference< XController > xController
const EditTextObject * mpEditText
static void ResetKeyBindings(ScOptionsUtil::KeyBindingType eType)
void SetText(const OUString &rStr)
bool setExtension(OUString const &rTheExtension, sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
void InvalidateStyleSheetUsage()
virtual ~ScDocShell() override
SC_DLLPUBLIC SCROW MaxRow() const
constexpr OUStringLiteral IsReadOnly(u"IsReadOnly")
SC_DLLPUBLIC SCTAB GetTableCount() const
SfxFrame & GetFrame() const
virtual bool SaveAs(SfxMedium &rMedium) override
std::unique_ptr< ScPaintLockData > m_pPaintLockData
bool IsOverflowCol() const
void SetLookUpColRowNames(bool bVal)
const OUString & GetPhysicalName() const
SC_DLLPUBLIC ScExternalRefManager * GetExternalRefManager() const
bool IsAutoCalcShellDisabled() const
SvStream * GetOutStream()
std::unique_ptr< ScDocFunc > m_pDocFunc
const SfxPoolItem * ExecuteSynchron(sal_uInt16 nSlot, const SfxPoolItem **pArgs=nullptr)
const char16_t pFilterExcel4[]
bool DetectiveRefresh(bool bAutomatic=false)
ScFormulaCell * mpFormula
SAL_DLLPRIVATE void UseSheetSaveEntries()
static std::shared_ptr< ConfigurationChanges > create(css::uno::Reference< css::uno::XComponentContext > const &context=comphelper::getProcessComponentContext())
std::unique_ptr< DataStream > mpDataStream
static void lcl_parseHtmlFilterOption(const OUString &rOption, LanguageType &rLang, bool &rDateConvert)
virtual bool Load(SfxMedium &rMedium) override
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
const OUString & GetName() const
void SetRefreshHandler(const Link< Timer *, void > &rLink)
SfxObjectCreateMode GetCreateMode() const
#define SO3_SC_CLASSID_60
void PrepareFormulaCalc()
Call this before any operations that might trigger one or more formula cells to get calculated...
void SetClipData(const css::uno::Reference< css::datatransfer::XTransferable2 > &xTransferable)
virtual bool LoadFrom(SfxMedium &rMedium) override
SfxUndoManager * mpUndoManager
void MarkUsedExternalReferences()
virtual bool importExcel2003XML(ScDocument &rDoc, SfxMedium &rMedium) const =0
ScViewData & GetViewData()
static ScDocument * GetClipDoc()
ScChangeTrack * GetChangeTrack() const
#define SCWARN_EXPORT_ASCII
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
bool IsDocumentModifiedPending() const
const css::uno::Sequence< sal_Int8 > & GetProtection() const
SfxItemPool & GetPool() const
void SetInsertingFromOtherDoc(bool bVal)
#define SCWARN_IMPORT_CELL_OVERFLOW
void SetError(ErrCode nError)
OutputDevice * GetDevice() const
SC_DLLPUBLIC bool GetCellArea(SCTAB nTab, SCCOL &rEndCol, SCROW &rEndRow) const
constexpr OUStringLiteral aData
virtual bool DoSaveCompleted(SfxMedium *pNewStor=nullptr, bool bRegisterRecent=true) override
void SetName(const OUString &rNew)
ScSheetSaveData * GetSheetSaveData()
SC_DLLPUBLIC const ScDocOptions & GetDocOptions() const
static bool HasAutomaticTableName(std::u16string_view rFilter)
void InvalidateStreamOnSave()
void SetMarkArea(const ScRange &rRange)
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
std::unique_ptr< ScAutoStyleList > m_pAutoStyleList
bool IsChartListenerCollectionNeedsUpdate() const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
#define TOOLS_WARN_EXCEPTION(area, stream)
bool getUserAllowsLinkUpdate() const
SC_DLLPUBLIC void CalcFormulaTree(bool bOnlyForced=false, bool bProgressBar=true, bool bSetAllDirty=true)
Calculate formula cells that are on the formula tree either partially, or in full.
bool IsImportingXML() const
void EnableExecuteLink(bool bVal)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
#define ERRCODE_IO_GENERAL
static SAL_DLLPRIVATE bool MoveFile(const INetURLObject &rSource, const INetURLObject &rDest)
virtual bool importGnumeric(ScDocument &rDoc, SfxMedium &rMedium) const =0
static OUString getProductName()
OUStringBuffer & truncateToLength(OUStringBuffer &rBuffer, sal_Int32 nLength)
static SAL_DLLPRIVATE bool KillFile(const INetURLObject &rURL)
const svl::SharedString * mpString
static OUString GetLotusFilterName()
std::unique_ptr< ScDocShellModificator, o3tl::default_delete< ScDocShellModificator > > m_pModificator
SAL_DLLPRIVATE SCTAB GetSaveTab()
static SC_DLLPUBLIC void Init()
DLL-init/exit-code must be linked to the DLL only.
SAL_DLLPRIVATE void ResetDrawObjectShell()
constexpr OUStringLiteral pFilterLotus
static SC_DLLPUBLIC double nScreenPPTY
Vertical pixel per twips factor.
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
sal_uInt16 m_nDocumentLock
bool GetHideFormula() const
bool IsForcedFormulaPending() const
virtual bool LoadFrom(SfxMedium &rMedium)
const OUString & GetValue() const
void RemoveDdeTopic(SfxObjectShell const *)
::tools::Long nLastColWidthExtra
const OUString & GetName() const
const char pFilterExcel95[]
#define SCERR_EXPORT_DATA
void SetPool(SfxItemPool *pNewPool)
std::size_t WriteBytes(const void *pData, std::size_t nSize)
virtual bool PrepareClose(bool bUI=true) override
bool hasExternalData() const
bool IsDetectiveDirty() const
OUString ScResId(const char *pId)
virtual bool Save() override
OUString GetBaseURL(bool bForSaving=false)
#define BCA_BRDCST_ALWAYS
std::unique_ptr< weld::CheckButton > m_xWarningOnBox
constexpr OUStringLiteral pFilterDif
void StartWritingUnicodeText()
SfxItemSet * GetItemSet() const
void BroadcastUno(const SfxHint &rHint)
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
virtual bool LoadExternal(SfxMedium &rMedium) override
SvStream & endlub(SvStream &rStrm)
SAL_DLLPRIVATE ErrCode DBaseExport(const OUString &rFullFileName, rtl_TextEncoding eCharSet, bool &bHasMemo)
bool GetShowSharedDocumentWarning() const
virtual HiddenInformation GetHiddenInformationState(HiddenInformation nStates)
bool ExportStream(SvStream &, const OUString &rBaseURL, SotClipboardFormatId)
const char pFilterEx97Temp[]
void Broadcast(const ScHint &rHint)
Broadcast wrapper, calls rHint.GetCell()->Broadcast() and AreaBroadcast() and TrackFormulas() Preferr...
void SetShowSharedDocumentWarning(bool bNew)
void SetFieldSeps(const OUString &rStr)
const std::shared_ptr< const SfxFilter > & GetFilter() const
SfxViewShell * GetViewShell() const
#define SCERR_IMPORT_UNKNOWN
SAL_DLLPRIVATE std::unique_ptr< ScDocFunc > CreateDocFunc()
virtual bool IsChangeRecording() const override
virtual void TerminateEditing() override
ScDBFunc * GetView() const
virtual bool GetProtectionHash(css::uno::Sequence< sal_Int8 > &rPasswordHash) override
const char pFilterExcel5[]
const char16_t pFilterRtf[]
SvStreamEndian GetEndian() const
void SetShowAccepted(bool bVal)
constexpr OUStringLiteral pFilterSc50
std::unique_ptr< ScOptSolverSave > m_pSolverSaveData
void SetInUndo(bool bSet)
void StopTemporaryChartLock()
const OUString & GetNonConvertibleChars() const
std::unique_ptr< ScSheetSaveData > m_pSheetSaveData
void SetStreamValid(SCTAB nTab, bool bSet, bool bIgnoreLock=false)
SC_DLLPUBLIC void SetDocOptions(const ScDocOptions &rOpt)
SFX_IMPL_OBJECTFACTORY(DrawDocShell, SvGlobalName(SO3_SIMPRESS_CLASSID),"simpress") void DrawDocShell
static ScTabViewShell * GetActiveViewShell()
sal_uInt16 GetTablesHintId() const
void setUserAllowsLinkUpdate(bool bNew)
bool IsOverflowRow() const
exports com.sun.star. document
virtual bool ConvertFrom(SfxMedium &rMedium) override
Any makeAny(Color const &value)
SfxEventHintId GetEventId() const
std::unique_ptr< ScFormatSaveData > m_pFormatSaveData
static SC_DLLPUBLIC OUString GetDocTabName(std::u16string_view rFileName, std::u16string_view rTabName)
static SAL_DLLPRIVATE bool IsDocument(const INetURLObject &rURL)
void ReadFromString(const OUString &rString)
void AsciiSave(SvStream &rStream, const ScImportOptions &rOpt)
bool IsOverflowCell() const
void SetStreamPath(const OUString &rPath)
void ErrorMessage(const char *pGlobStrId)
#define SCERR_IMPORT_CONNECT
void AfterXMLLoading(bool bRet)
#define SCWARN_IMPORT_ROW_OVERFLOW
void SetEndian(SvStreamEndian SvStreamEndian)
css::uno::Reference< css::frame::XController > GetController() const
SCTAB GetFirstSelected() const
static SC_DLLPUBLIC ScAbstractDialogFactory * Create()
virtual LockFileEntry GetLockData() override
ScExtDocOptions * GetExtDocOptions()
void UpdateAcceptChangesDialog()
#define SC_TEXT_CSV_FILTER_NAME
void SetDetectiveDirty(bool bSet)
void SetStreamCharSet(rtl_TextEncoding eCharSet)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
#define SVSTREAM_FILEFORMAT_ERROR
SAL_DLLPRIVATE bool SaveXML(SfxMedium *pMedium, const css::uno::Reference< css::embed::XStorage > &)
void InvalidateLastTableOpParams()
rtl_TextEncoding GetCharSet() const
rtl_TextEncoding GetStreamCharSet() const
const char16_t pFilterSylk[]
constexpr TypedWhichId< SvxHorJustifyItem > ATTR_HOR_JUSTIFY(129)
virtual CreateTabPage GetTabPageCreatorFunc(sal_uInt16 nId)=0
static OUString GetDBaseFilterName()
std::unique_ptr< DocShell_Impl > m_pImpl
Reference< XComponentContext > getProcessComponentContext()
SC_DLLPUBLIC ScChartListenerCollection * GetChartListenerCollection() const
static SC_DLLPUBLIC double nScreenPPTX
Horizontal pixel per twips factor.
bool needsPassHashRegen(const ScDocument &rDoc, ScPasswordHash eHash1, ScPasswordHash eHash2=PASSHASH_UNSPECIFIED)
Check for the compatibility of all password hashes.
void SetAutoCalcShellDisabled(bool bNew)
const ScDocument & GetDocument() const
SC_DLLPUBLIC void UpdateChartListenerCollection()
css::uno::Reference< ooo::vba::excel::XWorkbook > mxAutomationWorkbookObject
vcl::Window * GetWindow() const
#define SCWARN_IMPORT_COLUMN_OVERFLOW
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
static rtl_TextEncoding GetCharsetValue(const OUString &rCharSet)
virtual void SetProtectionPassword(const OUString &rPassword) override
ScDocShellModificator(const ScDocShellModificator &)=delete
void ClosingClipboardSource()
To be called at the clipboard document when closing a document that is the current clipboard source t...
SAL_DLLPRIVATE bool LoadXML(SfxMedium *pMedium, const css::uno::Reference< css::embed::XStorage > &)
static const sal_Unicode * UnicodeStrChr(const sal_Unicode *pStr, sal_Unicode c)
strchr() functionality on unicode, as long as we need it for FormulaToken etc.
bool IsEnableSetModified() const
void SetDocumentModified()
#define SC_COMPILER_FILE_TAB_SEP
bool IsInLinkUpdate() const
static void CreateAndSet(ScDocShell *pDocSh)
create ScModelObj and set at pDocSh (SetBaseModel)
virtual bool QuerySlotExecutable(sal_uInt16 nSlotId) override
OUString BuildString() const
static SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
virtual void SetModified(bool=true) override
void GetDocStat(ScDocStat &rDocStat)
void InvalidateAll(bool bWithMsg)
virtual bool importXLSX(ScDocument &rDoc, SfxMedium &rMedium) const =0
bool m_bDocumentModifiedPending
#define SAL_WARN(area, stream)
Reference< XSingleServiceFactory > xFactory
rtl_TextEncoding eCharSet
Reference< XModel > xModel
void(* f)(TrueTypeTable *)
void SetDrawModified()
SetDrawModified - without Formula update.
void setDataStream(DataStream *p)
constexpr OUStringLiteral pFilterAscii
SC_DLLPUBLIC void MakeTable(SCTAB nTab, bool _bNeedsNameCheck=true)
ScTabViewShell * GetBestViewShell(bool bOnlyVisible=true)
bool WriteUnicodeOrByteText(const OUString &rStr, rtl_TextEncoding eDestCharSet)
void StartChangeTracking()
void SetDocumentModifiedPending(bool bVal)
SC_DLLPUBLIC void SetExtDocOptions(std::unique_ptr< ScExtDocOptions > pNewOptions)
void SetFilterOptions(const OUString &rFilterOptions)
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
virtual void SetChangeRecording(bool bActivate, bool bLockAllViews=false) override
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
bool Export(bool bStylesOnly)
const DdeService * GetDdeService() const
bool IsIdleEnabled() const
bool WriteUniOrByteChar(sal_Unicode ch, rtl_TextEncoding eDestCharSet)
static bool WarningOnPassword(SfxMedium &rMedium)
Opens a query warning dialog.
const char16_t pFilterEx4Temp[]
void RefreshDirtyTableColumnNames()
void GetDocStat(ScDocStat &rDocStat)
virtual bool importCSV(ScDocument &rDoc, SfxMedium &rMedium) const =0
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
void SetTextSep(sal_Unicode c)
weld::Window * GetDialogParent()
parent window for dialogs Problem: OLE Server!
void SetError(ErrCode rErr)
static OUString GetErrorString(FormulaError nErrNumber)
SC_DLLPUBLIC ScFieldEditEngine & GetEditEngine()
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
Create before modifications of the document and destroy thereafter.
const char pFilterExcel97[]
bool bAutoCalcShellDisabled
SC_DLLPUBLIC bool GetAutoCalc() const
static OUString GetDifFilterName()
void SetShowChanges(bool bFlag)
OStringBuffer & padToLength(OStringBuffer &rBuffer, sal_Int32 nLength, char cFill= '\0')
SfxMedium * GetMedium() const