tdf#159444 Warn when View -> Field Names is activated

Change-Id: I0a839ab93ac50e701329d3203ae8e2e655ee748c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185213
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
This commit is contained in:
marus087
2025-05-14 10:50:56 +02:00
committed by Heiko Tietze
parent ae45f22fcf
commit 4e461bb4e3
6 changed files with 119 additions and 3 deletions
@@ -5426,6 +5426,12 @@
</info>
<value>true</value>
</prop>
<prop oor:name="QueryShowFieldName" oor:type="xs:boolean" oor:nillable="false">
<info>
<desc>Determines whether to show the field name when entering the field mode.</desc>
</info>
<value>true</value>
</prop>
<prop oor:name="QueryDeleteAllComments" oor:type="xs:boolean" oor:nillable="false">
<info>
<desc>Determines whether to confirm delete all comments or all by user.</desc>
+5
View File
@@ -1558,6 +1558,11 @@
#define STR_QUERY_INSMODE_TEXT NC_("STR_QUERY_INSMODE_TEXT", "The overwrite mode allows to type over text. It is indicated by a block cursor and at the statusbar. Press Insert again to switch back.")
#define STR_QUERY_INSMODE_QUESTION NC_("STR_QUERY_INSMODE_QUESTION", "Do you want to continue?")
// To translators: title, text, question for confirmation whether to activate Field Names
#define STR_QUERY_FIELDNAME_TITLE NC_("STR_QUERY_FIELDNAME_TITLE", "You activated Field Names")
#define STR_QUERY_FIELDNAME_TEXT NC_("STR_QUERY_FIELDNAME_TEXT", "This will show the names of fields not as they appear in the final document but with their internal identifiers.")
#define STR_QUERY_FIELDNAME_QUESTION NC_("STR_QUERY_FIELDNAME_QUESTION", "Do you want to activate Field Names?")
// To translators: title and question for confirmation whether to delete all comments / all comments by author; text intentionally empty
#define STR_QUERY_DELALLCOMMENTS_TITLE NC_("STR_QUERY_DELALLCOMMENTS_TITLE", "Confirm delete")
#define STR_QUERY_DELALLCOMMENTS_QUESTION NC_("STR_QUERY_DELALLCOMMENTS_QUESTION", "Are you sure you want to delete all comments?")
+18
View File
@@ -27,6 +27,8 @@
#include <unoframe.hxx>
#include <fldmgr.hxx>
#include <officecfg/Office/Common.hxx>
/// Test to assert layout / rendering result of Writer.
class SwLayoutWriter : public SwModelTestBase
{
@@ -761,6 +763,16 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInBody)
CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testFlyHiddenParagraph)
{
// disable Field Names warning dialog
const bool bAsk = officecfg::Office::Common::Misc::QueryShowFieldName::get();
std::shared_ptr<comphelper::ConfigurationChanges> xChanges;
if (bAsk)
{
xChanges = comphelper::ConfigurationChanges::create();
officecfg::Office::Common::Misc::QueryShowFieldName::set(false, xChanges);
xChanges->commit();
}
createSwDoc("fly_hidden_paragraph.fodt");
// first, disable both so para gets hidden
@@ -807,6 +819,12 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testFlyHiddenParagraph)
// so just hardcode it...
dispatchCommand(mxComponent, ".uno:Fieldnames", args);
Scheduler::ProcessEventsToIdle();
if (bAsk)
{
officecfg::Office::Common::Misc::QueryShowFieldName::set(true, xChanges);
xChanges->commit();
}
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testFieldHideSection)
+48
View File
@@ -40,6 +40,8 @@
#include <drawdoc.hxx>
#include <svx/svdpage.hxx>
#include <officecfg/Office/Common.hxx>
namespace
{
/// Test to assert layout / rendering result of Writer.
@@ -1505,6 +1507,16 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testKeepWithNextPlusFlyFollowTextFlow)
assertXPath(pXmlDoc, "/root/page", 1);
}
// disable Field Names warning dialog
const bool bAsk = officecfg::Office::Common::Misc::QueryShowFieldName::get();
std::shared_ptr<comphelper::ConfigurationChanges> xChanges;
if (bAsk)
{
xChanges = comphelper::ConfigurationChanges::create();
officecfg::Office::Common::Misc::QueryShowFieldName::set(false, xChanges);
xChanges->commit();
}
dispatchCommand(mxComponent, u".uno:Fieldnames"_ustr, {});
{
@@ -1535,6 +1547,12 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testKeepWithNextPlusFlyFollowTextFlow)
assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/infos/bounds", "height", u"276");
assertXPath(pXmlDoc, "/root/page", 1);
}
if (bAsk)
{
officecfg::Office::Common::Misc::QueryShowFieldName::set(true, xChanges);
xChanges->commit();
}
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf122607)
@@ -2431,6 +2449,15 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testHiddenParagraphFollowFrame)
dispatchCommand(mxComponent, ".uno:ShowHiddenParagraphs", argsSH);
});
// disable Field Names warning dialog
const bool bAsk = officecfg::Office::Common::Misc::QueryShowFieldName::get();
std::shared_ptr<comphelper::ConfigurationChanges> xChanges;
if (bAsk)
{
xChanges = comphelper::ConfigurationChanges::create();
officecfg::Office::Common::Misc::QueryShowFieldName::set(false, xChanges);
xChanges->commit();
}
uno::Sequence<beans::PropertyValue> argsSH(
comphelper::InitPropertySequence({ { "ShowHiddenParagraphs", uno::Any(true) } }));
dispatchCommand(mxComponent, ".uno:ShowHiddenParagraphs", argsSH);
@@ -2446,6 +2473,12 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testHiddenParagraphFollowFrame)
assertXPath(pXmlDoc, "/root/page[2]/body/txt", 2);
}
if (bAsk)
{
officecfg::Office::Common::Misc::QueryShowFieldName::set(true, xChanges);
xChanges->commit();
}
dispatchCommand(mxComponent, ".uno:ShowHiddenParagraphs", {});
{
@@ -2477,6 +2510,15 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testHiddenParagraphFlys)
dispatchCommand(mxComponent, ".uno:ShowHiddenParagraphs", argsSH);
});
// disable Field Names warning dialog
const bool bAsk = officecfg::Office::Common::Misc::QueryShowFieldName::get();
std::shared_ptr<comphelper::ConfigurationChanges> xChanges;
if (bAsk)
{
xChanges = comphelper::ConfigurationChanges::create();
officecfg::Office::Common::Misc::QueryShowFieldName::set(false, xChanges);
xChanges->commit();
}
uno::Sequence<beans::PropertyValue> argsSH(
comphelper::InitPropertySequence({ { "ShowHiddenParagraphs", uno::Any(true) } }));
dispatchCommand(mxComponent, ".uno:ShowHiddenParagraphs", argsSH);
@@ -2490,6 +2532,12 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testHiddenParagraphFlys)
assertXPath(pXmlDoc, "/root/page/body/txt[3]/anchored/fly/infos/bounds", "height", u"724");
}
if (bAsk)
{
officecfg::Office::Common::Misc::QueryShowFieldName::set(true, xChanges);
xChanges->commit();
}
dispatchCommand(mxComponent, ".uno:ShowHiddenParagraphs", {});
{
+18
View File
@@ -30,6 +30,8 @@
#include <dcontact.hxx>
#include <frameformats.hxx>
#include <officecfg/Office/Common.hxx>
namespace
{
/// Test to assert layout / rendering result of Writer.
@@ -46,6 +48,16 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, testHiddenSectionPageDescs)
{
createSwDoc("hidden-sections-with-pagestyles.odt");
// disable Field Names warning dialog
const bool bAsk = officecfg::Office::Common::Misc::QueryShowFieldName::get();
std::shared_ptr<comphelper::ConfigurationChanges> xChanges;
if (bAsk)
{
xChanges = comphelper::ConfigurationChanges::create();
officecfg::Office::Common::Misc::QueryShowFieldName::set(false, xChanges);
xChanges->commit();
}
// hide these just so that the height of the section is what is expected;
// otherwise height depends on which tests run previously
uno::Sequence<beans::PropertyValue> argsSH(
@@ -75,6 +87,12 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, testHiddenSectionPageDescs)
assertXPath(pXmlDoc, "/root/page[2]", "formatName", u"Folgeseite");
}
if (bAsk)
{
officecfg::Office::Common::Misc::QueryShowFieldName::set(true, xChanges);
xChanges->commit();
}
// toggle one section hidden and other visible
executeMacro(
u"vnd.sun.star.script:Standard.Module1.Main?language=Basic&location=document"_ustr);
+24 -3
View File
@@ -73,6 +73,8 @@
#include <sfx2/sidebar/SidebarController.hxx>
#include <strings.hrc>
using namespace ::com::sun::star;
SFX_IMPL_NAMED_VIEWFACTORY(SwView, "Default")
@@ -558,12 +560,31 @@ void SwView::ExecViewOptions(SfxRequest &rReq)
pOpt->SetViewAnyRuler( bFlag );
break;
case FN_VIEW_FIELDNAME:
{
if( STATE_TOGGLE == eState )
bFlag = !pOpt->IsFieldName() ;
pOpt->SetFieldName( bFlag );
const bool bDoAsk = officecfg::Office::Common::Misc::QueryShowFieldName::get();
short nresult = RET_YES;
if (bFlag && bDoAsk)
{
VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create();
auto pDlg = pFact->CreateQueryDialog(
GetWrtShell().GetView().GetFrameWeld(), SwResId(STR_QUERY_FIELDNAME_TITLE),
SwResId(STR_QUERY_FIELDNAME_TEXT), SwResId(STR_QUERY_FIELDNAME_QUESTION), true);
nresult = pDlg->Execute();
if (pDlg->ShowAgain() == false)
{
std::shared_ptr<comphelper::ConfigurationChanges> xChanges(
comphelper::ConfigurationChanges::create());
officecfg::Office::Common::Misc::QueryShowFieldName::set(false, xChanges);
xChanges->commit();
}
pDlg->disposeOnce();
}
if (nresult == RET_YES)
pOpt->SetFieldName(bFlag);
break;
}
case FN_VIEW_MARKS:
if( STATE_TOGGLE == eState )
bFlag = !lcl_IsViewMarks(*pOpt) ;