[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/inc sw/source xmloff/source
Bernhard Widl
bernhard.widl at cib.de
Tue Jan 9 13:33:53 UTC 2018
sw/inc/cmdid.h | 2 +
sw/inc/crsrsh.hxx | 5 ++
sw/inc/unoprnms.hxx | 2 +
sw/source/core/crsr/crbm.cxx | 25 ++++++++++++
sw/source/core/unocore/unobkm.cxx | 74 ++++++++++++++++++++++++++++++++++++-
sw/source/core/unocore/unomap1.cxx | 2 +
sw/source/ui/misc/bookmark.cxx | 2 -
xmloff/source/text/txtparae.cxx | 24 ++++++++++++
8 files changed, 133 insertions(+), 3 deletions(-)
New commits:
commit b3226f8133ef28a0cc7328e419e0bf54abd3fda1
Author: Bernhard Widl <bernhard.widl at cib.de>
Date: Fri Dec 22 17:39:15 2017 +0100
tdf#101856 create bookmarks w/ new hidden/condition attrs, and save as odt
Change-Id: Ib1df7a4c1477693aa2d0ec067635cdcbd393cebd
Reviewed-on: https://gerrit.libreoffice.org/47598
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 09cd1f48513c..36a93cef8ba7 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -814,6 +814,8 @@
#define FN_PARAM_PAM (FN_PARAM2+27) /* Point and Mark */
#define FN_TEXT_BOX (FN_PARAM2+28) /* TextBox Property*/
#define FN_PARAM_IGNORE_PROTECTED (FN_PARAM2+29) /* Ignore protected areas */
+#define FN_BOOKMARK_HIDDEN (FN_PARAM2+30) /* Hidden Property of bookmarks*/
+#define FN_BOOKMARK_CONDITION (FN_PARAM2+31) /* Condition Property of bookmarks*/
// Status: not more than 19!
#define FN_STAT_PAGE (FN_STAT + 1)
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 89c90a965cfd..8195259686eb 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -549,6 +549,11 @@ public:
const OUString& rName,
const OUString& rShortName,
IDocumentMarkAccess::MarkType eMark = IDocumentMarkAccess::MarkType::BOOKMARK);
+ ::sw::mark::IMark* SetBookmark(
+ const vcl::KeyCode&,
+ const OUString& rName,
+ bool rHide,
+ const OUString& rCondition);
bool GotoMark( const ::sw::mark::IMark* const pMark ); // sets CurrentCursor.SPoint
bool GotoMark( const ::sw::mark::IMark* const pMark, bool bAtStart );
bool GoNextBookmark(); // true, if there was one
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index 63589f273ce5..c700ee3bb468 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -331,6 +331,8 @@
#define UNO_NAME_IS_GLOBAL_DOCUMENT_SECTION "IsGlobalDocumentSection"
#define UNO_NAME_TEXT_FIELD "TextField"
#define UNO_NAME_BOOKMARK "Bookmark"
+#define UNO_NAME_BOOKMARK_HIDDEN "BookmarkHidden"
+#define UNO_NAME_BOOKMARK_CONDITION "BookmarkCondition"
#define UNO_NAME_TEXT_TABLE "TextTable"
#define UNO_NAME_CELL "Cell"
#define UNO_NAME_TEXT_FRAME "TextFrame"
diff --git a/sw/source/core/crsr/crbm.cxx b/sw/source/core/crsr/crbm.cxx
index 946af35c5cae..eff58b1f8ad6 100644
--- a/sw/source/core/crsr/crbm.cxx
+++ b/sw/source/core/crsr/crbm.cxx
@@ -99,6 +99,31 @@ namespace
}
// set CurrentCursor.SPoint
+// at CurrentCursor.SPoint
+::sw::mark::IMark* SwCursorShell::SetBookmark(
+ const vcl::KeyCode& rCode,
+ const OUString& rName,
+ bool rHide,
+ const OUString& rCondition)
+{
+ StartAction();
+ ::sw::mark::IMark* pMark = getIDocumentMarkAccess()->makeMark(
+ *GetCursor(),
+ rName,
+ IDocumentMarkAccess::MarkType::BOOKMARK, sw::mark::InsertMode::New);
+ ::sw::mark::IBookmark* pBookmark = dynamic_cast< ::sw::mark::IBookmark* >(pMark);
+ if (pBookmark)
+ {
+ pBookmark->SetKeyCode(rCode);
+ pBookmark->SetShortName(OUString());
+ pBookmark->Hide(rHide);
+ pBookmark->SetHideCondition(rCondition);
+ }
+ EndAction();
+ return pMark;
+}
+// set CurrentCursor.SPoint
+
bool SwCursorShell::GotoMark(const ::sw::mark::IMark* const pMark, bool bAtStart)
{
// watch Cursor-Moves
diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx
index feca7d3cdee8..bfd4bedc3975 100644
--- a/sw/source/core/unocore/unobkm.cxx
+++ b/sw/source/core/unocore/unobkm.cxx
@@ -52,13 +52,16 @@ public:
::comphelper::OInterfaceContainerHelper2 m_EventListeners;
SwDoc * m_pDoc;
::sw::mark::IMark * m_pRegisteredBookmark;
- OUString m_sMarkName;
+ OUString m_sMarkName;
+ bool m_bHidden;
+ OUString m_HideCondition;
Impl( SwDoc *const pDoc, ::sw::mark::IMark *const /*pBookmark*/)
: SwClient()
, m_EventListeners(m_Mutex)
, m_pDoc(pDoc)
, m_pRegisteredBookmark(nullptr)
+ , m_bHidden(false)
{
// DO NOT registerInMark here! (because SetXBookmark would delete rThis)
}
@@ -106,6 +109,14 @@ void SwXBookmark::Impl::registerInMark(SwXBookmark & rThis,
else if (m_pRegisteredBookmark)
{
m_sMarkName = m_pRegisteredBookmark->GetName();
+
+ // the following applies only to bookmarks (not to fieldmarks)
+ IBookmark* pBookmark = dynamic_cast<IBookmark*>(m_pRegisteredBookmark);
+ if (pBookmark)
+ {
+ m_bHidden = pBookmark->IsHidden();
+ m_HideCondition = pBookmark->GetHideCondition();
+ }
m_pRegisteredBookmark->Remove(this);
}
m_pRegisteredBookmark = pBkmk;
@@ -408,11 +419,46 @@ SwXBookmark::getPropertySetInfo() throw (uno::RuntimeException, std::exception)
void SAL_CALL
SwXBookmark::setPropertyValue(const OUString& PropertyName,
- const uno::Any& /*rValue*/)
+ const uno::Any& rValue)
throw (beans::UnknownPropertyException, beans::PropertyVetoException,
lang::IllegalArgumentException, lang::WrappedTargetException,
uno::RuntimeException, std::exception)
{
+ if (PropertyName == UNO_NAME_BOOKMARK_HIDDEN)
+ {
+ bool bNewValue = false;
+ if (!(rValue >>= bNewValue))
+ throw lang::IllegalArgumentException("Property BookmarkHidden requires value of type boolean", nullptr, 0);
+
+ IBookmark* pBookmark = dynamic_cast<IBookmark*>(m_pImpl->m_pRegisteredBookmark);
+ if (pBookmark)
+ {
+ pBookmark->Hide(bNewValue);
+ }
+ else
+ {
+ m_pImpl->m_bHidden = bNewValue;
+ }
+ return;
+ }
+ else if (PropertyName == UNO_NAME_BOOKMARK_CONDITION)
+ {
+ OUString newValue;
+ if (!(rValue >>= newValue))
+ throw lang::IllegalArgumentException("Property BookmarkCondition requires value of type string", nullptr, 0);
+
+ IBookmark* pBookmark = dynamic_cast<IBookmark*>(m_pImpl->m_pRegisteredBookmark);
+ if (pBookmark)
+ {
+ pBookmark->SetHideCondition(newValue);
+ }
+ else
+ {
+ m_pImpl->m_HideCondition = newValue;
+ }
+ return;
+ }
+
// nothing to set here
throw lang::IllegalArgumentException("Property is read-only: "
+ PropertyName, static_cast< cppu::OWeakObject * >(this), 0 );
@@ -431,6 +477,30 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException,
{
aRet <<= getName();
}
+ else if (rPropertyName == UNO_NAME_BOOKMARK_HIDDEN)
+ {
+ IBookmark* pBookmark = dynamic_cast<IBookmark*>(m_pImpl->m_pRegisteredBookmark);
+ if (pBookmark)
+ {
+ aRet <<= pBookmark->IsHidden();
+ }
+ else
+ {
+ aRet <<= m_pImpl->m_bHidden;
+ }
+ }
+ else if (rPropertyName == UNO_NAME_BOOKMARK_CONDITION)
+ {
+ IBookmark* pBookmark = dynamic_cast<IBookmark*>(m_pImpl->m_pRegisteredBookmark);
+ if (pBookmark)
+ {
+ aRet <<= pBookmark->GetHideCondition();
+ }
+ else
+ {
+ aRet <<= m_pImpl->m_HideCondition;
+ }
+ }
}
return aRet;
}
diff --git a/sw/source/core/unocore/unomap1.cxx b/sw/source/core/unocore/unomap1.cxx
index bdf5820168ff..6e236d7613f6 100644
--- a/sw/source/core/unocore/unomap1.cxx
+++ b/sw/source/core/unocore/unomap1.cxx
@@ -952,6 +952,8 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetBookmarkPropertyMap
{
{ OUString(UNO_LINK_DISPLAY_NAME), FN_PARAM_LINK_DISPLAY_NAME, cppu::UnoType<OUString>::get(), PropertyAttribute::READONLY, 0xff},
COMMON_TEXT_CONTENT_PROPERTIES
+ { OUString(UNO_NAME_BOOKMARK_HIDDEN), FN_BOOKMARK_HIDDEN, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0 },
+ { OUString(UNO_NAME_BOOKMARK_CONDITION), FN_BOOKMARK_CONDITION, cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0 },
{ OUString(), 0, css::uno::Type(), 0, 0 }
};
diff --git a/sw/source/ui/misc/bookmark.cxx b/sw/source/ui/misc/bookmark.cxx
index 625399a349b3..fd086577387f 100644
--- a/sw/source/ui/misc/bookmark.cxx
+++ b/sw/source/ui/misc/bookmark.cxx
@@ -208,7 +208,7 @@ IMPL_LINK_NOARG_TYPED(SwInsertBookmarkDlg, RenameHdl, Button*, void)
IMPL_LINK_NOARG_TYPED(SwInsertBookmarkDlg, InsertHdl, Button*, void)
{
OUString sBookmark = m_pEditBox->GetText();
- rSh.SetBookmark(vcl::KeyCode(), sBookmark, OUString());
+ rSh.SetBookmark(vcl::KeyCode(), sBookmark, m_pHideCB->IsChecked(), m_pConditionED->GetText());
rReq.AppendItem(SfxStringItem(FN_INSERT_BOOKMARK, sBookmark));
rReq.Done();
if (!rReq.IsDone())
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index 462f655d642f..41bd0d503898 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -2529,6 +2529,30 @@ void XMLTextParagraphExport::exportTextMark(
GetExport().AddAttributesRDFa(xTextContent);
}
+ // bookmark-start: add attributes hidden and condition
+ if (nElement == 1)
+ {
+ Reference<XPropertySet> bkmkProps(rPropSet->getPropertyValue(rProperty), UNO_QUERY);
+ Reference<XPropertySetInfo> bkmkPropInfo(bkmkProps->getPropertySetInfo(), UNO_QUERY);
+ OUString sHidden("BookmarkHidden");
+ if (bkmkPropInfo->hasPropertyByName(sHidden))
+ {
+ bool bHidden = false;
+ bkmkProps->getPropertyValue(sHidden) >>= bHidden;
+ if (bHidden)
+ {
+ GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, "hidden", "true");
+ OUString sCondition("BookmarkCondition");
+ if (bkmkPropInfo->hasPropertyByName(sCondition))
+ {
+ OUString sBookmarkCondition;
+ bkmkProps->getPropertyValue(sCondition) >>= sBookmarkCondition;
+ GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, "condition", sBookmarkCondition);
+ }
+ }
+ }
+ }
+
// export element
DBG_ASSERT(pElements != nullptr, "illegal element array");
DBG_ASSERT(nElement >= 0, "illegal element number");
More information about the Libreoffice-commits
mailing list