summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/xmloff/xmltoken.hxx2
-rw-r--r--schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng2
-rw-r--r--sw/inc/authfld.hxx24
-rw-r--r--sw/inc/helpids.h4
-rw-r--r--sw/inc/strings.hrc2
-rw-r--r--sw/inc/toxe.hxx3
-rw-r--r--sw/qa/core/text/text.cxx6
-rw-r--r--sw/source/core/fields/authfld.cxx33
-rw-r--r--sw/source/core/text/EnhancedPDFExportHelper.cxx18
-rw-r--r--sw/source/ui/index/cnttab.cxx2
-rw-r--r--sw/source/ui/index/swuiidxmrk.cxx65
-rw-r--r--sw/source/uibase/docvw/edtwin2.cxx9
-rw-r--r--sw/source/uibase/shells/textsh1.cxx33
-rw-r--r--sw/source/uibase/utlui/initui.cxx2
-rw-r--r--sw/source/uibase/wrtsh/wrtsh2.cxx23
-rw-r--r--sw/uiconfig/swriter/ui/bibliofragment.ui41
-rw-r--r--xmloff/qa/unit/text.cxx6
-rw-r--r--xmloff/source/core/xmltoken.cxx2
-rw-r--r--xmloff/source/text/txtflde.cxx12
-rw-r--r--xmloff/source/text/txtfldi.cxx6
-rw-r--r--xmloff/source/token/tokens.txt2
21 files changed, 152 insertions, 145 deletions
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index 3ea2e7ee8335..09bb105d17e9 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -3469,8 +3469,8 @@ namespace xmloff::token {
XML_MARGIN_GUTTER,
XML_LOCAL_URL,
+ XML_TARGET_TYPE,
XML_TARGET_URL,
- XML_USE_TARGET_URL,
// Math ml
XML_DIR,
diff --git a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
index a3900e4f31c7..5fe259dbd5e5 100644
--- a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
+++ b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
@@ -3262,8 +3262,8 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
<rng:name>text:issn</rng:name>
<rng:name>loext:local-url</rng:name>
<!-- TODO no proposal -->
+ <rng:name>loext:target-type</rng:name>
<rng:name>loext:target-url</rng:name>
- <rng:name>loext:use-target-url</rng:name>
</rng:choice>
<rng:ref name="string"/>
</rng:attribute>
diff --git a/sw/inc/authfld.hxx b/sw/inc/authfld.hxx
index 26e4843a6ad2..9aef5085cec6 100644
--- a/sw/inc/authfld.hxx
+++ b/sw/inc/authfld.hxx
@@ -167,6 +167,16 @@ class SW_DLLPUBLIC SwAuthorityField final : public SwField
virtual std::unique_ptr<SwField> Copy() const override;
public:
+ enum TargetType : sal_uInt16
+ {
+ UseDisplayURL = 0,
+ UseTargetURL = 1,
+ None = 2,
+ BibliographyTableRow = 3,
+ // BibliographyTablePage = 4, // TODO: implement
+ };
+
+
/// For internal use only, in general continue using ExpandField() instead.
OUString ConditionalExpandAuthIdentifier(SwRootFrame const* pLayout) const;
@@ -199,13 +209,17 @@ public:
OUString GetAuthority(const SwRootFrame *pLayout,
const SwForm *pTOX = nullptr) const;
- bool UseTargetURL() const;
-
- bool HasURL() const;
+ /**
+ * Returns which target should be used when the entry
+ * (the standalone field, such as '[ASDF]', not in the table) is clicked.
+ */
+ TargetType GetTargetType() const;
+ /**
+ * Returns absolute target URL in case there is one (GetTargetType() should be checked).
+ * If there isn't one, the result is undefined.
+ */
OUString GetAbsoluteURL() const;
- bool HasTargetURL() const;
- OUString GetAbsoluteTargetURL() const;
/**
* Returns full URI for the URL, relative if specified
* \param bRelative whether the path should be relative (when dealing with local files)
diff --git a/sw/inc/helpids.h b/sw/inc/helpids.h
index 90906bf66729..6bf90929ab00 100644
--- a/sw/inc/helpids.h
+++ b/sw/inc/helpids.h
@@ -76,9 +76,9 @@ inline constexpr OUStringLiteral HID_AUTH_FIELD_CUSTOM4 = u"SW_HID_AUTH_FIELD_CU
inline constexpr OUStringLiteral HID_AUTH_FIELD_CUSTOM5 = u"SW_HID_AUTH_FIELD_CUSTOM5";
inline constexpr OUStringLiteral HID_AUTH_FIELD_ISBN = u"SW_HID_AUTH_FIELD_ISBN";
inline constexpr OUStringLiteral HID_AUTH_FIELD_LOCAL_URL = u"SW_HID_AUTH_FIELD_LOCAL_URL";
+inline constexpr OUStringLiteral HID_AUTH_FIELD_TARGET_TYPE = u"SW_HID_AUTH_FIELD_TARGET_TYPE";
inline constexpr OUStringLiteral HID_AUTH_FIELD_TARGET_URL = u"SW_HID_AUTH_FIELD_TARGET_URL";
-inline constexpr OUStringLiteral HID_AUTH_FIELD_USE_TARGET_URL
- = u"SW_HID_AUTH_FIELD_USE_TARGET_URL";
+
inline constexpr OUStringLiteral HID_BUSINESS_FMT_PAGE = u"SW_HID_BUSINESS_FMT_PAGE";
inline constexpr OUStringLiteral HID_BUSINESS_FMT_PAGE_CONT = u"SW_HID_BUSINESS_FMT_PAGE_CONT";
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index 31a3e86667f5..2c7eb4069688 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -822,8 +822,8 @@
#define STR_AUTH_FIELD_CUSTOM5 NC_("STR_AUTH_FIELD_CUSTOM5", "User-defined5")
#define STR_AUTH_FIELD_ISBN NC_("STR_AUTH_FIELD_ISBN", "ISBN")
#define STR_AUTH_FIELD_LOCAL_URL NC_("STR_AUTH_FIELD_LOCAL_URL", "Local copy")
+#define STR_AUTH_FIELD_TARGET_TYPE NC_("STR_AUTH_FIELD_TARGET_TYPE", "Mark link target")
#define STR_AUTH_FIELD_TARGET_URL NC_("STR_AUTH_FIELD_TARGET_URL", "Target URL")
-#define STR_AUTH_FIELD_USE_TARGET_URL NC_("STR_AUTH_FIELD_USE_TARGET_URL", "Use Target URL as hyperlink")
#define STR_IDXMRK_EDIT NC_("STR_IDXMRK_EDIT", "Edit Index Entry")
#define STR_IDXMRK_INSERT NC_("STR_IDXMRK_INSERT", "Insert Index Entry")
diff --git a/sw/inc/toxe.hxx b/sw/inc/toxe.hxx
index 05084c84c2e8..667c7f2b67d6 100644
--- a/sw/inc/toxe.hxx
+++ b/sw/inc/toxe.hxx
@@ -115,8 +115,9 @@ enum ToxAuthorityField
AUTH_FIELD_CUSTOM5,
AUTH_FIELD_ISBN,
AUTH_FIELD_LOCAL_URL,
+ AUTH_FIELD_TARGET_TYPE,
AUTH_FIELD_TARGET_URL,
- AUTH_FIELD_USE_TARGET_URL,
+
AUTH_FIELD_END
};
diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx
index b233d2ecf499..36332102e3b0 100644
--- a/sw/qa/core/text/text.cxx
+++ b/sw/qa/core/text/text.cxx
@@ -226,8 +226,8 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testBibliographyUrlPdfExport4)
comphelper::makePropertyValue("Identifier", OUString("AT")),
comphelper::makePropertyValue("Author", OUString("Author")),
comphelper::makePropertyValue("Title", OUString("Title")),
+ comphelper::makePropertyValue("TargetType", OUString("1")), // 1 == UseTargetURL
comphelper::makePropertyValue("TargetURL", OUString("#page=1")),
- comphelper::makePropertyValue("UseTargetURL", OUString("true")),
};
xField->setPropertyValue("Fields", uno::Any(aFields));
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
@@ -262,7 +262,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testBibliographyUrlPdfExport5)
comphelper::makePropertyValue("Identifier", OUString("AT")),
comphelper::makePropertyValue("Author", OUString("Author")),
comphelper::makePropertyValue("Title", OUString("Title")),
- comphelper::makePropertyValue("UseTargetURL", OUString("true")),
+ comphelper::makePropertyValue("TargetType", OUString("3")), // 3 == BibliographyTableRow
};
xField->setPropertyValue("Fields", uno::Any(aFields));
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
@@ -309,7 +309,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testBibliographyUrlPdfExport6)
comphelper::makePropertyValue("Identifier", OUString("AT")),
comphelper::makePropertyValue("Author", OUString("AuthorName")),
comphelper::makePropertyValue("Title", OUString("Title")),
- comphelper::makePropertyValue("UseTargetURL", OUString("true")),
+ comphelper::makePropertyValue("TargetType", OUString("3")), // 3 == BibliographyTableRow
};
xField->setPropertyValue("Fields", uno::Any(aFields));
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
diff --git a/sw/source/core/fields/authfld.cxx b/sw/source/core/fields/authfld.cxx
index a388d8015132..77b640739760 100644
--- a/sw/source/core/fields/authfld.cxx
+++ b/sw/source/core/fields/authfld.cxx
@@ -639,37 +639,16 @@ OUString SwAuthorityField::GetAuthority(const SwRootFrame* pLayout, const SwForm
return aText;
}
-bool SwAuthorityField::UseTargetURL() const
+SwAuthorityField::TargetType SwAuthorityField::GetTargetType() const
{
- const OUString& rValue = GetAuthEntry()->GetAuthorField(AUTH_FIELD_USE_TARGET_URL);
- return rValue.toAsciiLowerCase() == "true";
-}
-
-bool SwAuthorityField::HasURL() const
-{
- const OUString& rURL = GetAuthEntry()->GetAuthorField(AUTH_FIELD_URL);
- return !rURL.isEmpty();
+ return SwAuthorityField::TargetType(GetAuthEntry()->GetAuthorField(AUTH_FIELD_TARGET_TYPE).toInt32());
}
OUString SwAuthorityField::GetAbsoluteURL() const
{
- const OUString& rURL = GetAuthEntry()->GetAuthorField(AUTH_FIELD_URL);
- SwDoc* pDoc = static_cast<SwAuthorityFieldType*>(GetTyp())->GetDoc();
- SwDocShell* pDocShell = pDoc->GetDocShell();
- OUString aBasePath = pDocShell->getDocumentBaseURL();
- return INetURLObject::GetAbsURL(aBasePath, rURL, INetURLObject::EncodeMechanism::WasEncoded,
- INetURLObject::DecodeMechanism::WithCharset);
-}
-
-bool SwAuthorityField::HasTargetURL() const
-{
- const OUString& rURL = GetAuthEntry()->GetAuthorField(AUTH_FIELD_TARGET_URL);
- return !rURL.isEmpty();
-}
-
-OUString SwAuthorityField::GetAbsoluteTargetURL() const
-{
- const OUString& rURL = GetAuthEntry()->GetAuthorField(AUTH_FIELD_TARGET_URL);
+ const OUString& rURL = GetAuthEntry()->GetAuthorField(
+ GetTargetType() == SwAuthorityField::TargetType::UseDisplayURL
+ ? AUTH_FIELD_URL : AUTH_FIELD_TARGET_URL);
SwDoc* pDoc = static_cast<SwAuthorityFieldType*>(GetTyp())->GetDoc();
SwDocShell* pDocShell = pDoc->GetDocShell();
OUString aBasePath = pDocShell->getDocumentBaseURL();
@@ -779,8 +758,8 @@ const char* const aFieldNames[] =
"Custom5",
"ISBN",
"LocalURL",
+ "TargetType",
"TargetURL",
- "UseTargetURL"
};
void SwAuthEntry::dumpAsXml(xmlTextWriterPtr pWriter) const
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index 7e39716cd252..431137a92257 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -2470,12 +2470,16 @@ void SwEnhancedPDFExportHelper::ExportAuthorityEntryLinks()
const auto& rAuthorityField
= *static_cast<const SwAuthorityField*>(pFormatField->GetField());
- if ((!rAuthorityField.UseTargetURL() && rAuthorityField.HasURL())
- || (rAuthorityField.UseTargetURL() && rAuthorityField.HasTargetURL()))
+ if (auto targetType = rAuthorityField.GetTargetType();
+ targetType == SwAuthorityField::TargetType::UseDisplayURL
+ || targetType == SwAuthorityField::TargetType::UseTargetURL)
{
- // Since the conditions indicate usage of a URL link to it
- const OUString& rURL = rAuthorityField.GetAuthEntry()->GetAuthorField(
- rAuthorityField.UseTargetURL() ? AUTH_FIELD_TARGET_URL : AUTH_FIELD_URL);
+ // Since the target type specifies to use an URL, link to it
+ const OUString& rURL = rAuthorityField.GetAbsoluteURL();
+ if (rURL.getLength() == 0)
+ {
+ continue;
+ }
const SwTextNode& rTextNode = pFormatField->GetTextField()->GetTextNode();
if (!lcl_TryMoveToNonHiddenField(mrSh, rTextNode, *pFormatField))
@@ -2503,9 +2507,9 @@ void SwEnhancedPDFExportHelper::ExportAuthorityEntryLinks()
}
mrSh.SwCursorShell::ClearMark();
}
- else if (rAuthorityField.UseTargetURL())
+ else if (targetType == SwAuthorityField::TargetType::BibliographyTableRow)
{
- // Since the bibliography mark doesn't have target URL, try linking to a bibliography table
+ // As the target type specifies, try linking to a bibliography table row
sal_Int32 nDestId = -1;
std::unordered_map<const SwTOXBase*, OUString> vFormattedFieldStrings;
diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx
index 1de0e701ff88..fc6f096372f2 100644
--- a/sw/source/ui/index/cnttab.cxx
+++ b/sw/source/ui/index/cnttab.cxx
@@ -1899,8 +1899,8 @@ namespace
STR_AUTH_FIELD_CUSTOM5,
STR_AUTH_FIELD_ISBN,
STR_AUTH_FIELD_LOCAL_URL,
+ STR_AUTH_FIELD_TARGET_TYPE,
STR_AUTH_FIELD_TARGET_URL,
- STR_AUTH_FIELD_USE_TARGET_URL,
};
}
diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx
index 22c1bc7409c8..b810ad14aef8 100644
--- a/sw/source/ui/index/swuiidxmrk.cxx
+++ b/sw/source/ui/index/swuiidxmrk.cxx
@@ -1093,13 +1093,15 @@ class SwCreateAuthEntryDlg_Impl : public weld::GenericDialogController
std::unique_ptr<weld::Button> m_xLocalBrowseButton;
std::unique_ptr<weld::CheckButton> m_xLocalPageCB;
std::unique_ptr<weld::SpinButton> m_xLocalPageSB;
- std::unique_ptr<weld::CheckButton> m_xUseTargetURLCB;
+ std::unique_ptr<weld::ComboBox> m_xTargetTypeListBox;
+ weld::Entry* m_xTargetURLField;
DECL_LINK(IdentifierHdl, weld::ComboBox&, void);
DECL_LINK(ShortNameHdl, weld::Entry&, void);
DECL_LINK(EnableHdl, weld::ComboBox&, void);
DECL_LINK(BrowseHdl, weld::Button&, void);
DECL_LINK(PageNumHdl, weld::Toggleable&, void);
+ DECL_LINK(TargetTypeHdl, weld::ComboBox&, void);
public:
SwCreateAuthEntryDlg_Impl(weld::Window* pParent,
@@ -1150,7 +1152,7 @@ const TextInfo aTextInfoArr[] =
{AUTH_FIELD_ANNOTE, HID_AUTH_FIELD_ANNOTE },
{AUTH_FIELD_NOTE, HID_AUTH_FIELD_NOTE },
{AUTH_FIELD_URL, HID_AUTH_FIELD_URL },
- {AUTH_FIELD_USE_TARGET_URL, HID_AUTH_FIELD_USE_TARGET_URL },
+ {AUTH_FIELD_TARGET_TYPE, HID_AUTH_FIELD_TARGET_TYPE },
{AUTH_FIELD_TARGET_URL, HID_AUTH_FIELD_TARGET_URL },
{AUTH_FIELD_LOCAL_URL, HID_AUTH_FIELD_LOCAL_URL },
{AUTH_FIELD_CUSTOM1, HID_AUTH_FIELD_CUSTOM1 },
@@ -1572,8 +1574,8 @@ namespace
STR_AUTH_FIELD_CUSTOM5,
STR_AUTH_FIELD_ISBN,
STR_AUTH_FIELD_LOCAL_URL,
+ STR_AUTH_FIELD_TARGET_TYPE,
STR_AUTH_FIELD_TARGET_URL,
- STR_AUTH_FIELD_USE_TARGET_URL,
};
}
@@ -1662,33 +1664,43 @@ SwCreateAuthEntryDlg_Impl::SwCreateAuthEntryDlg_Impl(weld::Window* pParent,
m_xIdentifierBox->set_help_id(aCurInfo.pHelpId);
m_aFixedTexts.back()->set_mnemonic_widget(m_xIdentifierBox.get());
}
- else if (AUTH_FIELD_USE_TARGET_URL == aCurInfo.nToxField)
+ else if (AUTH_FIELD_TARGET_TYPE == aCurInfo.nToxField)
{
- m_pBoxes[nIndex] = m_aBuilders.back()->weld_box("togglebox");
-
+ m_xTargetTypeListBox = m_aBuilders.back()->weld_combo_box("listbox-target-type");
if (bLeft)
- m_aOrigContainers.back()->move(m_pBoxes[nIndex].get(), m_xLeft.get());
+ m_aOrigContainers.back()->move(m_xTargetTypeListBox.get(), m_xLeft.get());
else
- m_aOrigContainers.back()->move(m_pBoxes[nIndex].get(), m_xRight.get());
-
- m_pBoxes[nIndex]->set_grid_left_attach(1);
- m_pBoxes[nIndex]->set_grid_top_attach(bLeft ? nLeftRow : nRightRow);
- m_pBoxes[nIndex]->set_hexpand(true);
+ m_aOrigContainers.back()->move(m_xTargetTypeListBox.get(), m_xRight.get());
- m_xUseTargetURLCB = m_aBuilders.back()->weld_check_button("usetargeturlcb");
- m_xUseTargetURLCB->set_active(m_bNewEntryMode
- || pFields[aCurInfo.nToxField].toAsciiLowerCase() == "true");
- m_xUseTargetURLCB->set_grid_left_attach(1);
- m_xUseTargetURLCB->set_grid_top_attach(bLeft ? nLeftRow : nRightRow);
- m_xUseTargetURLCB->set_hexpand(true);
- m_xUseTargetURLCB->show();
- m_xUseTargetURLCB->set_help_id(aCurInfo.pHelpId);
- m_aFixedTexts.back()->set_mnemonic_widget(m_xUseTargetURLCB.get());
+ if(!pFields[aCurInfo.nToxField].isEmpty())
+ {
+ m_xTargetTypeListBox->set_active(pFields[aCurInfo.nToxField].toInt32());
+ }
+ else if(m_bNewEntryMode)
+ {
+ // For new documents, set value to "BibliographyTableRow"
+ m_xTargetTypeListBox->set_active(SwAuthorityField::TargetType::BibliographyTableRow);
+ }
+ m_xTargetTypeListBox->set_grid_left_attach(1);
+ m_xTargetTypeListBox->set_grid_top_attach(bLeft ? nLeftRow : nRightRow);
+ m_xTargetTypeListBox->set_hexpand(true);
+ m_xTargetTypeListBox->show();
+ m_xTargetTypeListBox->connect_changed(LINK(this, SwCreateAuthEntryDlg_Impl, TargetTypeHdl));
+ m_xTargetTypeListBox->set_help_id(aCurInfo.pHelpId);
+ m_aFixedTexts.back()->set_mnemonic_widget(m_xTargetTypeListBox.get());
}
else
{
m_pBoxes[nIndex] = m_aBuilders.back()->weld_box("vbox");
m_pEdits[nIndex] = m_aBuilders.back()->weld_entry("entry");
+
+ if (AUTH_FIELD_TARGET_URL == aCurInfo.nToxField)
+ {
+ m_xTargetURLField = m_pEdits[nIndex].get();
+ m_xTargetURLField->set_sensitive(
+ m_xTargetTypeListBox->get_active() == SwAuthorityField::TargetType::UseTargetURL);
+ }
+
if (bLeft)
m_aOrigContainers.back()->move(m_pBoxes[nIndex].get(), m_xLeft.get());
else
@@ -1777,10 +1789,10 @@ OUString SwCreateAuthEntryDlg_Impl::GetEntryText(ToxAuthorityField eField) cons
return m_xIdentifierBox->get_active_text();
}
- if (AUTH_FIELD_USE_TARGET_URL == eField)
+ if (AUTH_FIELD_TARGET_TYPE == eField)
{
- assert(m_xUseTargetURLCB && "No UseTargetURL");
- return (m_xUseTargetURLCB->get_active() ? OUString("true") : OUString("false"));
+ assert(m_xTargetTypeListBox && "No TargetType ListBox");
+ return OUString::number(m_xTargetTypeListBox->get_active());
}
for(int nIndex = 0; nIndex < AUTH_FIELD_END; nIndex++)
@@ -1844,6 +1856,11 @@ IMPL_LINK(SwCreateAuthEntryDlg_Impl, EnableHdl, weld::ComboBox&, rBox, void)
m_xLocalBrowseButton->show();
};
+IMPL_LINK(SwCreateAuthEntryDlg_Impl, TargetTypeHdl, weld::ComboBox&, rBox, void)
+{
+ m_xTargetURLField->set_sensitive(rBox.get_active() == SwAuthorityField::TargetType::UseTargetURL);
+}
+
IMPL_LINK(SwCreateAuthEntryDlg_Impl, BrowseHdl, weld::Button&, rButton, void)
{
sfx2::FileDialogHelper aFileDlg(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
diff --git a/sw/source/uibase/docvw/edtwin2.cxx b/sw/source/uibase/docvw/edtwin2.cxx
index a98d38cf1e79..1c9563782050 100644
--- a/sw/source/uibase/docvw/edtwin2.cxx
+++ b/sw/source/uibase/docvw/edtwin2.cxx
@@ -575,16 +575,13 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt)
const auto pAuthorityField = static_cast<const SwAuthorityField*>(pField);
sText = pAuthorityField->GetAuthority(rSh.GetLayout());
- if (!pAuthorityField->UseTargetURL() && pAuthorityField->HasURL())
+ if (auto t = pAuthorityField->GetTargetType();
+ t == SwAuthorityField::TargetType::UseDisplayURL
+ || t == SwAuthorityField::TargetType::UseTargetURL)
{
const OUString& rURL = pAuthorityField->GetAbsoluteURL();
sText += "\n" + SfxHelp::GetURLHelpText(rURL);
}
- else if (pAuthorityField->UseTargetURL() && pAuthorityField->HasTargetURL())
- {
- const OUString& rURL = pAuthorityField->GetAbsoluteTargetURL();
- sText += "\n" + SfxHelp::GetURLHelpText(rURL);
- }
break;
}
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index cdef2ec7d2bb..fd0d4454492a 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -1812,6 +1812,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
if(SfxItemState::SET <= aSet.GetItemState( RES_TXTATR_INETFMT ))
{
const SwFormatINetFormat& rINetFormat = aSet.Get(RES_TXTATR_INETFMT);
+
if (nSlot == SID_OPEN_HYPERLINK)
{
rWrtSh.ClickToINetAttr(rINetFormat);
@@ -1829,22 +1830,26 @@ void SwTextShell::Execute(SfxRequest &rReq)
if (pField && pField->GetTyp()->Which() == SwFieldIds::TableOfAuthorities)
{
const auto& rAuthorityField = *static_cast<const SwAuthorityField*>(pField);
- if ((!rAuthorityField.UseTargetURL() && rAuthorityField.HasURL())
- || (rAuthorityField.UseTargetURL() && rAuthorityField.HasTargetURL()))
+ OUString targetURL = "";
+
+ if (auto targetType = rAuthorityField.GetTargetType();
+ targetType == SwAuthorityField::TargetType::UseDisplayURL
+ || targetType == SwAuthorityField::TargetType::UseTargetURL)
{
// Bibliography entry with URL also provides a hyperlink.
- const OUString& rURL
- = rAuthorityField.GetAuthEntry()->GetAuthorField(
- rAuthorityField.UseTargetURL() ? AUTH_FIELD_TARGET_URL : AUTH_FIELD_URL);
-
+ targetURL = rAuthorityField.GetAbsoluteURL();
+ }
+
+ if (targetURL.getLength() > 0)
+ {
if (nSlot == SID_OPEN_HYPERLINK)
{
- ::LoadURL(rWrtSh, rURL, LoadUrlFlags::NewView, /*rTargetFrameName=*/OUString());
+ ::LoadURL(rWrtSh, targetURL, LoadUrlFlags::NewView, /*rTargetFrameName=*/OUString());
}
else if (nSlot == SID_COPY_HYPERLINK_LOCATION)
{
::uno::Reference< datatransfer::clipboard::XClipboard > xClipboard = GetView().GetEditWin().GetClipboard();
- vcl::unohelper::TextDataObject::CopyStringTo(rURL, xClipboard, SfxViewShell::Current());
+ vcl::unohelper::TextDataObject::CopyStringTo(targetURL, xClipboard, SfxViewShell::Current());
}
}
}
@@ -2571,12 +2576,14 @@ void SwTextShell::GetState( SfxItemSet &rSet )
SwField* pField = rSh.GetCurField();
if (pField && pField->GetTyp()->Which() == SwFieldIds::TableOfAuthorities)
{
- // Bibliography entry with URL also provides a hyperlink.
const auto& rAuthorityField = *static_cast<const SwAuthorityField*>(pField);
- if (!rAuthorityField.UseTargetURL())
- bAuthorityFieldURL = rAuthorityField.HasURL();
- else
- bAuthorityFieldURL = rAuthorityField.HasTargetURL();
+ if (auto targetType = rAuthorityField.GetTargetType();
+ targetType == SwAuthorityField::TargetType::UseDisplayURL
+ || targetType == SwAuthorityField::TargetType::UseTargetURL)
+ {
+ // Check if the Bibliography entry has a target URL
+ bAuthorityFieldURL = rAuthorityField.GetAbsoluteURL().getLength() > 0;
+ }
}
if (SfxItemState::SET > aSet.GetItemState(RES_TXTATR_INETFMT, false)
&& !bAuthorityFieldURL)
diff --git a/sw/source/uibase/utlui/initui.cxx b/sw/source/uibase/utlui/initui.cxx
index 51e2b8e8894e..2444d652ea73 100644
--- a/sw/source/uibase/utlui/initui.cxx
+++ b/sw/source/uibase/utlui/initui.cxx
@@ -236,8 +236,8 @@ namespace
STR_AUTH_FIELD_CUSTOM5,
STR_AUTH_FIELD_ISBN,
STR_AUTH_FIELD_LOCAL_URL,
+ STR_AUTH_FIELD_TARGET_TYPE,
STR_AUTH_FIELD_TARGET_URL,
- STR_AUTH_FIELD_USE_TARGET_URL,
};
}
diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx b/sw/source/uibase/wrtsh/wrtsh2.cxx
index 5136659b708d..f4881304f95c 100644
--- a/sw/source/uibase/wrtsh/wrtsh2.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh2.cxx
@@ -414,23 +414,18 @@ void SwWrtShell::ClickToField(const SwField& rField, bool bExecHyperlinks)
Point vStartPoint = GetCursor_()->GetPtPos();
const SwAuthorityField* pField = static_cast<const SwAuthorityField*>(&rField);
- if (!pField->UseTargetURL() && pField->HasURL())
+ if (auto targetType = pField->GetTargetType();
+ targetType == SwAuthorityField::TargetType::UseDisplayURL
+ || targetType == SwAuthorityField::TargetType::UseTargetURL)
{
- // Since user didn't opt in to use Target URL, open standard URL
-
- const OUString& rURL = pField->GetAbsoluteURL();
- ::LoadURL(*this, rURL, LoadUrlFlags::NewView, /*rTargetFrameName=*/OUString());
- }
- else if (pField->UseTargetURL() && pField->HasTargetURL())
- {
- // Since user opted in to use Target URL and field has Target URL, use it
-
- const OUString& rURL = pField->GetAbsoluteTargetURL();
- ::LoadURL(*this, rURL, LoadUrlFlags::NewView, /*rTargetFrameName=*/OUString());
+ // Since the user selected target type with URL, try to use it if not empty
+ if (const OUString& rURL = pField->GetAbsoluteURL();
+ rURL.getLength() > 0)
+ ::LoadURL(*this, rURL, LoadUrlFlags::NewView, /*rTargetFrameName=*/OUString());
}
- else if (pField->UseTargetURL())
+ else if (targetType == SwAuthorityField::TargetType::BibliographyTableRow)
{
- // Since user opted in to use Target URL but the field doesn't have Target URL,
+ // Since the user selected to target Bibliography Table Row,
// try finding matching bibliography table line
const bool bWasViewLocked = IsViewLocked();
diff --git a/sw/uiconfig/swriter/ui/bibliofragment.ui b/sw/uiconfig/swriter/ui/bibliofragment.ui
index 2652711b4472..011541a26371 100644
--- a/sw/uiconfig/swriter/ui/bibliofragment.ui
+++ b/sw/uiconfig/swriter/ui/bibliofragment.ui
@@ -109,30 +109,6 @@
</packing>
</child>
<child>
- <object class="GtkBox" id="togglebox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkCheckButton" id="usetargeturlcb">
- <property name="label" translatable="yes" context=""></property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
<object class="GtkComboBoxText" id="listbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -172,5 +148,22 @@
<property name="top_attach">0</property>
</packing>
</child>
+ <child>
+ <object class="GtkComboBoxText" id="listbox-target-type">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <items>
+ <item id="0" translatable="yes" context="bibliofragment|targettype0">Open Display URL</item>
+ <item id="1" translatable="yes" context="bibliofragment|targettype1">Open Target URL</item>
+ <item id="2" translatable="yes" context="bibliofragment|targettype2">None</item>
+ <item id="3" translatable="yes" context="bibliofragment|targettype3">Jump to Bibliography Table Row</item>
+ </items>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
</object>
</interface>
diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx
index 532d97774e2f..c70600340183 100644
--- a/xmloff/qa/unit/text.cxx
+++ b/xmloff/qa/unit/text.cxx
@@ -133,8 +133,8 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testBibliographyTargetURL1)
uno::Sequence<beans::PropertyValue> aFields = {
comphelper::makePropertyValue("Identifier", OUString("AT")),
comphelper::makePropertyValue("URL", OUString("https://display.url/test1.pdf#page=1")),
+ comphelper::makePropertyValue("TargetType", OUString("1")),
comphelper::makePropertyValue("TargetURL", OUString("https://target.url/test2.pdf#page=2")),
- comphelper::makePropertyValue("UseTargetURL", OUString("true")),
};
xField->setPropertyValue("Fields", uno::Any(aFields));
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
@@ -165,8 +165,8 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testBibliographyTargetURL1)
CPPUNIT_ASSERT_EQUAL(OUString("https://target.url/test2.pdf#page=2"),
aMap["TargetURL"].get<OUString>());
- CPPUNIT_ASSERT(aMap.find("UseTargetURL") != aMap.end());
- CPPUNIT_ASSERT_EQUAL(OUString("true"), aMap["UseTargetURL"].get<OUString>());
+ CPPUNIT_ASSERT(aMap.find("TargetType") != aMap.end());
+ CPPUNIT_ASSERT_EQUAL(OUString("1"), aMap["TargetType"].get<OUString>());
}
CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testCommentTableBorder)
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 30ea348588ce..e0189451803b 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -3473,8 +3473,8 @@ namespace xmloff::token {
TOKEN("margin-gutter", XML_MARGIN_GUTTER),
TOKEN("local-url", XML_LOCAL_URL),
+ TOKEN("target-type", XML_TARGET_TYPE),
TOKEN("target-url", XML_TARGET_URL),
- TOKEN("use-target-url", XML_USE_TARGET_URL),
TOKEN("dir", XML_DIR ),
TOKEN("displaystyle", XML_DISPLAYSTYLE ),
diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx
index 67e9137cc615..a6a0936423d8 100644
--- a/xmloff/source/text/txtflde.cxx
+++ b/xmloff/source/text/txtflde.cxx
@@ -2713,8 +2713,8 @@ void XMLTextFieldExport::ProcessBibliographyData(
sStr = GetExport().GetRelativeReference(sStr);
}
sal_uInt16 nPrefix = XML_NAMESPACE_TEXT;
- if (eElement == XML_LOCAL_URL || eElement == XML_TARGET_URL
- || eElement == XML_USE_TARGET_URL)
+ if (eElement == XML_LOCAL_URL || eElement == XML_TARGET_TYPE
+ || eElement == XML_TARGET_URL)
{
nPrefix = XML_NAMESPACE_LO_EXT;
}
@@ -3415,13 +3415,13 @@ enum XMLTokenEnum XMLTextFieldExport::MapBibliographyFieldName(std::u16string_vi
{
eName = XML_LOCAL_URL;
}
- else if (sName == u"TargetURL")
+ else if (sName == u"TargetType")
{
- eName = XML_TARGET_URL;
+ eName = XML_TARGET_TYPE;
}
- else if (sName == u"UseTargetURL")
+ else if (sName == u"TargetURL")
{
- eName = XML_USE_TARGET_URL;
+ eName = XML_TARGET_URL;
}
else
{
diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx
index e2fad89cac9d..af89551343c8 100644
--- a/xmloff/source/text/txtfldi.cxx
+++ b/xmloff/source/text/txtfldi.cxx
@@ -3113,12 +3113,12 @@ const char* XMLBibliographyFieldImportContext::MapBibliographyFieldName(
case XML_LOCAL_URL:
pName = "LocalURL";
break;
+ case XML_TARGET_TYPE:
+ pName = "TargetType";
+ break;
case XML_TARGET_URL:
pName = "TargetURL";
break;
- case XML_USE_TARGET_URL:
- pName = "UseTargetURL";
- break;
default:
assert(false && "Unknown bibliography info data");
pName = nullptr;
diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt
index 8a5615a0a790..d1932e24e103 100644
--- a/xmloff/source/token/tokens.txt
+++ b/xmloff/source/token/tokens.txt
@@ -3220,8 +3220,8 @@ page-content-top
page-content-bottom
margin-gutter
local-url
+target-type
target-url
-use-target-url
dir
displaystyle
infinity