summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-03-10 08:58:00 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-03-10 14:31:54 +0100
commite75f6e549eb825c310d16d11babf0fba5ee7fd7a (patch)
tree288931d9af316722f730b9909e2d9cda37da2625 /sfx2
parentb84f5a0efa4a24a3e8074bc27fb21529b9c4d3a6 (diff)
sfx2: make SfxClassificationHelper not require a full doc shell
So that input filters can build their own doc properties and can also use CheckPaste() without having the full original document around. Change-Id: I0b8a63702f73ce04e8728a360b56ab9d1ca67af1
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/view/classificationcontroller.cxx2
-rw-r--r--sfx2/source/view/classificationhelper.cxx40
-rw-r--r--sfx2/source/view/viewfrm.cxx4
3 files changed, 22 insertions, 24 deletions
diff --git a/sfx2/source/view/classificationcontroller.cxx b/sfx2/source/view/classificationcontroller.cxx
index 1dc8134e1cf5..788eddfdb000 100644
--- a/sfx2/source/view/classificationcontroller.cxx
+++ b/sfx2/source/view/classificationcontroller.cxx
@@ -164,7 +164,7 @@ void ClassificationCategoriesController::statusChanged(const frame::FeatureState
if (!pObjectShell)
return;
- SfxClassificationHelper aHelper(*pObjectShell);
+ SfxClassificationHelper aHelper(pObjectShell->getDocProperties());
if (m_pCategories->GetEntryCount() == 0)
{
std::vector<OUString> aNames = aHelper.GetBACNames();
diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx
index 6950048fae82..2abcff8eda27 100644
--- a/sfx2/source/view/classificationhelper.cxx
+++ b/sfx2/source/view/classificationhelper.cxx
@@ -321,18 +321,18 @@ public:
SfxClassificationCategory m_aCategory;
/// Possible categories of a policy to choose from.
std::vector<SfxClassificationCategory> m_aCategories;
- SfxObjectShell& m_rObjectShell;
+ const uno::Reference<document::XDocumentProperties>& m_xDocumentProperties;
- Impl(SfxObjectShell& rObjectShell);
+ Impl(const uno::Reference<document::XDocumentProperties>& xDocumentProperties);
void parsePolicy();
- /// Synchronize m_aLabels back to the object shell.
- void pushToObjectShell();
+ /// Synchronize m_aLabels back to the document properties.
+ void pushToDocumentProperties();
/// Set the classification start date to the system time.
void setStartValidity();
};
-SfxClassificationHelper::Impl::Impl(SfxObjectShell& rObjectShell)
- : m_rObjectShell(rObjectShell)
+SfxClassificationHelper::Impl::Impl(const uno::Reference<document::XDocumentProperties>& xDocumentProperties)
+ : m_xDocumentProperties(xDocumentProperties)
{
}
@@ -384,10 +384,9 @@ void SfxClassificationHelper::Impl::setStartValidity()
}
}
-void SfxClassificationHelper::Impl::pushToObjectShell()
+void SfxClassificationHelper::Impl::pushToDocumentProperties()
{
- uno::Reference<document::XDocumentProperties> xDocumentProperties = m_rObjectShell.getDocProperties();
- uno::Reference<beans::XPropertyContainer> xPropertyContainer = xDocumentProperties->getUserDefinedProperties();
+ uno::Reference<beans::XPropertyContainer> xPropertyContainer = m_xDocumentProperties->getUserDefinedProperties();
uno::Reference<beans::XPropertySet> xPropertySet(xPropertyContainer, uno::UNO_QUERY);
uno::Sequence<beans::Property> aProperties = xPropertySet->getPropertySetInfo()->getProperties();
std::map<OUString, OUString> aLabels = m_aCategory.m_aLabels;
@@ -403,14 +402,13 @@ void SfxClassificationHelper::Impl::pushToObjectShell()
}
catch (const uno::Exception& rException)
{
- SAL_WARN("sfx.view", "pushToObjectShell() failed for property " << rLabel.first << ": " << rException.Message);
+ SAL_WARN("sfx.view", "pushDocumentProperties() failed for property " << rLabel.first << ": " << rException.Message);
}
}
}
-bool SfxClassificationHelper::IsClassified(SfxObjectShell& rObjectShell)
+bool SfxClassificationHelper::IsClassified(const uno::Reference<document::XDocumentProperties>& xDocumentProperties)
{
- uno::Reference<document::XDocumentProperties> xDocumentProperties = rObjectShell.getDocProperties();
uno::Reference<beans::XPropertyContainer> xPropertyContainer = xDocumentProperties->getUserDefinedProperties();
if (!xPropertyContainer.is())
return false;
@@ -426,15 +424,16 @@ bool SfxClassificationHelper::IsClassified(SfxObjectShell& rObjectShell)
return false;
}
-SfxClassificationCheckPasteResult SfxClassificationHelper::CheckPaste(SfxObjectShell& rSource, SfxObjectShell& rDestination)
+SfxClassificationCheckPasteResult SfxClassificationHelper::CheckPaste(const uno::Reference<document::XDocumentProperties>& xSource,
+ const uno::Reference<document::XDocumentProperties>& xDestination)
{
- bool bSourceClassified = SfxClassificationHelper::IsClassified(rSource);
+ bool bSourceClassified = SfxClassificationHelper::IsClassified(xSource);
if (!bSourceClassified)
// No classification on the source side. Return early, regardless the
// state of the destination side.
return SfxClassificationCheckPasteResult::None;
- bool bDestinationClassified = SfxClassificationHelper::IsClassified(rDestination);
+ bool bDestinationClassified = SfxClassificationHelper::IsClassified(xDestination);
if (bSourceClassified && !bDestinationClassified)
{
// Paste from a classified document to a non-classified one -> deny.
@@ -442,8 +441,8 @@ SfxClassificationCheckPasteResult SfxClassificationHelper::CheckPaste(SfxObjectS
}
// Remaining case: paste between two classified documents.
- SfxClassificationHelper aSource(rSource);
- SfxClassificationHelper aDestination(rDestination);
+ SfxClassificationHelper aSource(xSource);
+ SfxClassificationHelper aDestination(xDestination);
if (aSource.GetImpactScale() != aDestination.GetImpactScale())
// It's possible to compare them if they have the same scale.
return SfxClassificationCheckPasteResult::None;
@@ -455,10 +454,9 @@ SfxClassificationCheckPasteResult SfxClassificationHelper::CheckPaste(SfxObjectS
return SfxClassificationCheckPasteResult::None;
}
-SfxClassificationHelper::SfxClassificationHelper(SfxObjectShell& rObjectShell)
- : m_pImpl(o3tl::make_unique<Impl>(rObjectShell))
+SfxClassificationHelper::SfxClassificationHelper(const uno::Reference<document::XDocumentProperties>& xDocumentProperties)
+ : m_pImpl(o3tl::make_unique<Impl>(xDocumentProperties))
{
- uno::Reference<document::XDocumentProperties> xDocumentProperties = rObjectShell.getDocProperties();
uno::Reference<beans::XPropertyContainer> xPropertyContainer = xDocumentProperties->getUserDefinedProperties();
if (!xPropertyContainer.is())
return;
@@ -660,7 +658,7 @@ void SfxClassificationHelper::SetBACName(const OUString& rName)
m_pImpl->m_aCategory = *it;
m_pImpl->setStartValidity();
- m_pImpl->pushToObjectShell();
+ m_pImpl->pushToDocumentProperties();
SfxViewFrame* pViewFrame = SfxViewFrame::Current();
if (!pViewFrame)
return;
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index bea3126630c1..9775ff00da44 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -1343,10 +1343,10 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
}
}
- if (SfxClassificationHelper::IsClassified(*xObjSh.get()))
+ if (SfxClassificationHelper::IsClassified(xObjSh->getDocProperties()))
{
// Document has BAILS properties, display an infobar accordingly.
- SfxClassificationHelper aHelper(*xObjSh.get());
+ SfxClassificationHelper aHelper(xObjSh->getDocProperties());
aHelper.UpdateInfobar(*this);
}