summaryrefslogtreecommitdiff
path: root/sfx2/source
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2021-04-30 13:00:35 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-04-30 16:03:35 +0200
commit857caa5fc69b92e781457a1b67a89aa051c2d70f (patch)
tree7437d7f6345f9dea81f4203517549c48fa971eae /sfx2/source
parentb9097800f4f997de2325bc9e588e6caea7a563c7 (diff)
tdf#79049 speed up OOXML workbook load
we spend a lot of time in ScAttrArray::GetLastVisibleAttr which appears to be very expensive for this worksheet. This is re-computed every time we enter SfxBaseModel::getArgs Reduce the recomputation by introducing a new method which only retrieves specific SfxBaseModel arguments. This takes the load time from 5m9 to 1m9 for me. Change-Id: I605fae0faa94760c7d6993877c9559ea5dc813cd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114905 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2/source')
-rw-r--r--sfx2/source/doc/objmisc.cxx20
-rw-r--r--sfx2/source/doc/objxtor.cxx4
-rw-r--r--sfx2/source/doc/sfxbasemodel.cxx116
-rw-r--r--sfx2/source/view/frame2.cxx2
-rw-r--r--sfx2/source/view/sfxbasecontroller.cxx3
5 files changed, 84 insertions, 61 deletions
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index 81298eb8ff11..18042c7eca70 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -1871,48 +1871,48 @@ bool SfxObjectShell::IsContinueImportOnFilterExceptions(std::u16string_view aErr
bool SfxObjectShell::isEditDocLocked() const
{
- Reference<XModel> xModel = GetModel();
+ Reference<XModel3> xModel = GetModel();
if (!xModel.is())
return false;
if (!officecfg::Office::Common::Misc::AllowEditReadonlyDocs::get())
return true;
- comphelper::NamedValueCollection aArgs(xModel->getArgs());
+ comphelper::NamedValueCollection aArgs(xModel->getArgs2( { "LockEditDoc" } ));
return aArgs.getOrDefault("LockEditDoc", false);
}
bool SfxObjectShell::isContentExtractionLocked() const
{
- Reference<XModel> xModel = GetModel();
+ Reference<XModel3> xModel = GetModel();
if (!xModel.is())
return false;
- comphelper::NamedValueCollection aArgs(xModel->getArgs());
+ comphelper::NamedValueCollection aArgs(xModel->getArgs2( { "LockContentExtraction" } ));
return aArgs.getOrDefault("LockContentExtraction", false);
}
bool SfxObjectShell::isExportLocked() const
{
- Reference<XModel> xModel = GetModel();
+ Reference<XModel3> xModel = GetModel();
if (!xModel.is())
return false;
- comphelper::NamedValueCollection aArgs(xModel->getArgs());
+ comphelper::NamedValueCollection aArgs(xModel->getArgs2( { "LockExport" } ));
return aArgs.getOrDefault("LockExport", false);
}
bool SfxObjectShell::isPrintLocked() const
{
- Reference<XModel> xModel = GetModel();
+ Reference<XModel3> xModel = GetModel();
if (!xModel.is())
return false;
- comphelper::NamedValueCollection aArgs(xModel->getArgs());
+ comphelper::NamedValueCollection aArgs(xModel->getArgs2( { "LockPrint" } ));
return aArgs.getOrDefault("LockPrint", false);
}
bool SfxObjectShell::isSaveLocked() const
{
- Reference<XModel> xModel = GetModel();
+ Reference<XModel3> xModel = GetModel();
if (!xModel.is())
return false;
- comphelper::NamedValueCollection aArgs(xModel->getArgs());
+ comphelper::NamedValueCollection aArgs(xModel->getArgs2( { "LockSave" } ));
return aArgs.getOrDefault("LockSave", false);
}
diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx
index 6c6c7852c8d2..70b2e1e2e486 100644
--- a/sfx2/source/doc/objxtor.cxx
+++ b/sfx2/source/doc/objxtor.cxx
@@ -827,7 +827,7 @@ uno::Sequence< OUString > SfxObjectShell::GetEventNames()
}
-css::uno::Reference< css::frame::XModel > SfxObjectShell::GetModel() const
+css::uno::Reference< css::frame::XModel3 > SfxObjectShell::GetModel() const
{
return GetBaseModel();
}
@@ -843,7 +843,7 @@ void SfxObjectShell::SetBaseModel( SfxBaseModel* pModel )
}
-css::uno::Reference< css::frame::XModel > SfxObjectShell::GetBaseModel() const
+css::uno::Reference< css::frame::XModel3 > SfxObjectShell::GetBaseModel() const
{
return pImpl->pBaseModel;
}
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index fa5d405dfdd0..0af671f6ae0a 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -931,9 +931,15 @@ OUString SAL_CALL SfxBaseModel::getURL()
// frame::XModel
-
Sequence< beans::PropertyValue > SAL_CALL SfxBaseModel::getArgs()
{
+ return getArgs2({});
+}
+
+// frame::XModel3
+
+Sequence< beans::PropertyValue > SAL_CALL SfxBaseModel::getArgs2(const Sequence<OUString> & requestedArgsSeq )
+{
SfxModelGuard aGuard( *this );
if (!SfxApplication::Get()) // tdf#113755
@@ -942,6 +948,10 @@ Sequence< beans::PropertyValue > SAL_CALL SfxBaseModel::getArgs()
return m_pData->m_seqArguments;
}
+ std::set<std::u16string_view> requestedArgs;
+ for (OUString const & s : requestedArgsSeq)
+ requestedArgs.insert(s);
+
if ( m_pData->m_pObjectShell.is() )
{
Sequence< beans::PropertyValue > seqArgsNew;
@@ -958,67 +968,79 @@ Sequence< beans::PropertyValue > SAL_CALL SfxBaseModel::getArgs()
sal_Int32 nNewLength = seqArgsNew.getLength();
- // "WinExtent" property should be updated always.
- // We can store it now to overwrite an old value
- // since it is not from ItemSet
- tools::Rectangle aTmpRect = m_pData->m_pObjectShell->GetVisArea( ASPECT_CONTENT );
- aTmpRect = OutputDevice::LogicToLogic(aTmpRect, MapMode(m_pData->m_pObjectShell->GetMapUnit()), MapMode(MapUnit::Map100thMM));
-
- Sequence< sal_Int32 > aRectSeq(4);
- aRectSeq[0] = aTmpRect.Left();
- aRectSeq[1] = aTmpRect.Top();
- aRectSeq[2] = aTmpRect.IsWidthEmpty() ? aTmpRect.Left() : aTmpRect.Right();
- aRectSeq[3] = aTmpRect.IsHeightEmpty() ? aTmpRect.Top() : aTmpRect.Bottom();
+ if (requestedArgs.empty() || requestedArgs.count(u"WinExtent"))
+ {
+ // "WinExtent" property should be updated always.
+ // We can store it now to overwrite an old value
+ // since it is not from ItemSet
+ tools::Rectangle aTmpRect = m_pData->m_pObjectShell->GetVisArea( ASPECT_CONTENT );
+ aTmpRect = OutputDevice::LogicToLogic(aTmpRect, MapMode(m_pData->m_pObjectShell->GetMapUnit()), MapMode(MapUnit::Map100thMM));
+
+ Sequence< sal_Int32 > aRectSeq(4);
+ aRectSeq[0] = aTmpRect.Left();
+ aRectSeq[1] = aTmpRect.Top();
+ aRectSeq[2] = aTmpRect.IsWidthEmpty() ? aTmpRect.Left() : aTmpRect.Right();
+ aRectSeq[3] = aTmpRect.IsHeightEmpty() ? aTmpRect.Top() : aTmpRect.Bottom();
- seqArgsNew.realloc( ++nNewLength );
- seqArgsNew[ nNewLength - 1 ].Name = "WinExtent";
- seqArgsNew[ nNewLength - 1 ].Value <<= aRectSeq;
+ seqArgsNew.realloc( ++nNewLength );
+ seqArgsNew[ nNewLength - 1 ].Name = "WinExtent";
+ seqArgsNew[ nNewLength - 1 ].Value <<= aRectSeq;
+ }
- if ( !m_pData->m_aPreusedFilterName.isEmpty() )
+ if (requestedArgs.empty() || requestedArgs.count(u"PreusedFilterName"))
{
- seqArgsNew.realloc( ++nNewLength );
- seqArgsNew[ nNewLength - 1 ].Name = "PreusedFilterName";
- seqArgsNew[ nNewLength - 1 ].Value <<= m_pData->m_aPreusedFilterName;
+ if ( !m_pData->m_aPreusedFilterName.isEmpty() )
+ {
+ seqArgsNew.realloc( ++nNewLength );
+ seqArgsNew[ nNewLength - 1 ].Name = "PreusedFilterName";
+ seqArgsNew[ nNewLength - 1 ].Value <<= m_pData->m_aPreusedFilterName;
+ }
}
- SfxViewFrame* pFrame = SfxViewFrame::GetFirst( m_pData->m_pObjectShell.get() );
- if ( pFrame )
+ if (requestedArgs.empty() || requestedArgs.count(u"DocumentBorder"))
{
- SvBorder aBorder = pFrame->GetBorderPixelImpl();
+ SfxViewFrame* pFrame = SfxViewFrame::GetFirst( m_pData->m_pObjectShell.get() );
+ if ( pFrame )
+ {
+ SvBorder aBorder = pFrame->GetBorderPixelImpl();
- Sequence< sal_Int32 > aBorderSeq(4);
- aBorderSeq[0] = aBorder.Left();
- aBorderSeq[1] = aBorder.Top();
- aBorderSeq[2] = aBorder.Right();
- aBorderSeq[3] = aBorder.Bottom();
+ Sequence< sal_Int32 > aBorderSeq(4);
+ aBorderSeq[0] = aBorder.Left();
+ aBorderSeq[1] = aBorder.Top();
+ aBorderSeq[2] = aBorder.Right();
+ aBorderSeq[3] = aBorder.Bottom();
- seqArgsNew.realloc( ++nNewLength );
- seqArgsNew[ nNewLength - 1 ].Name = "DocumentBorder";
- seqArgsNew[ nNewLength - 1 ].Value <<= aBorderSeq;
+ seqArgsNew.realloc( ++nNewLength );
+ seqArgsNew[ nNewLength - 1 ].Name = "DocumentBorder";
+ seqArgsNew[ nNewLength - 1 ].Value <<= aBorderSeq;
+ }
}
- // only the values that are not supported by the ItemSet must be cached here
- Sequence< beans::PropertyValue > aFinalCache;
- sal_Int32 nFinalLength = 0;
-
- for ( const auto& rOrg : std::as_const(m_pData->m_seqArguments) )
+ if (requestedArgs.empty())
{
- auto bNew = std::none_of(seqArgsOld.begin(), seqArgsOld.end(),
- [&rOrg](const beans::PropertyValue& rOld){ return rOld.Name == rOrg.Name; });
- if ( bNew )
+ // only the values that are not supported by the ItemSet must be cached here
+ Sequence< beans::PropertyValue > aFinalCache;
+ sal_Int32 nFinalLength = 0;
+
+ for ( const auto& rOrg : std::as_const(m_pData->m_seqArguments) )
{
- // the entity with this name should be new for seqArgsNew
- // since it is not supported by transformer
+ auto bNew = std::none_of(seqArgsOld.begin(), seqArgsOld.end(),
+ [&rOrg](const beans::PropertyValue& rOld){ return rOld.Name == rOrg.Name; });
+ if ( bNew )
+ {
+ // the entity with this name should be new for seqArgsNew
+ // since it is not supported by transformer
- seqArgsNew.realloc( ++nNewLength );
- seqArgsNew[ nNewLength - 1 ] = rOrg;
+ seqArgsNew.realloc( ++nNewLength );
+ seqArgsNew[ nNewLength - 1 ] = rOrg;
- aFinalCache.realloc( ++nFinalLength );
- aFinalCache[ nFinalLength - 1 ] = rOrg;
+ aFinalCache.realloc( ++nFinalLength );
+ aFinalCache[ nFinalLength - 1 ] = rOrg;
+ }
}
- }
- m_pData->m_seqArguments = aFinalCache;
+ m_pData->m_seqArguments = aFinalCache;
+ }
return seqArgsNew;
}
@@ -4228,7 +4250,7 @@ Reference< frame::XController2 > SAL_CALL SfxBaseModel::createViewController(
pBaseController->SetCreationArguments_Impl( i_rArguments );
// some initial view settings, coming from our most recent attachResource call
- ::comphelper::NamedValueCollection aDocumentLoadArgs( getArgs() );
+ ::comphelper::NamedValueCollection aDocumentLoadArgs( getArgs2( { "ViewOnly", "PluginMode" } ) );
if ( aDocumentLoadArgs.getOrDefault( "ViewOnly", false ) )
pViewFrame->GetFrame().SetMenuBarOn_Impl( false );
diff --git a/sfx2/source/view/frame2.cxx b/sfx2/source/view/frame2.cxx
index 3e96664527e0..990f46a53f86 100644
--- a/sfx2/source/view/frame2.cxx
+++ b/sfx2/source/view/frame2.cxx
@@ -381,7 +381,7 @@ bool SfxFrame::IsMenuBarOn_Impl() const
void SfxFrame::PrepareForDoc_Impl( SfxObjectShell& i_rDoc )
{
- const ::comphelper::NamedValueCollection aDocumentArgs( i_rDoc.GetModel()->getArgs() );
+ const ::comphelper::NamedValueCollection aDocumentArgs( i_rDoc.GetModel()->getArgs2( { "Hidden", "PluginMode" } ) );
// hidden?
OSL_ENSURE( !pImpl->bHidden, "when does this happen?" );
diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx
index a74674a82917..8f5bfddba32d 100644
--- a/sfx2/source/view/sfxbasecontroller.cxx
+++ b/sfx2/source/view/sfxbasecontroller.cxx
@@ -1224,7 +1224,8 @@ void SfxBaseController::ConnectSfxFrame_Impl( const ConnectSfxFrame i_eConnect )
if ( i_eConnect == E_CONNECT )
{
- ::comphelper::NamedValueCollection aDocumentArgs( getModel()->getArgs() );
+ css::uno::Reference<css::frame::XModel3> xModel(getModel(), css::uno::UNO_QUERY_THROW);
+ ::comphelper::NamedValueCollection aDocumentArgs( xModel->getArgs2( { "PluginMode" } ) );
const sal_Int16 nPluginMode = aDocumentArgs.getOrDefault( "PluginMode", sal_Int16( 0 ) );
const bool bHasPluginMode = ( nPluginMode != 0 );