[Libreoffice-commits] core.git: 2 commits - include/sfx2 sfx2/source sw/source vcl/jsdialog

2022-11-20 Thread Skyler Grey (via logerrit)
 include/sfx2/dinfdlg.hxx |   19 +
 sfx2/source/dialog/dinfdlg.cxx   |  115 ---
 sw/source/ui/frmdlg/cption.cxx   |7 ++
 sw/source/uibase/inc/cption.hxx  |1 
 sw/source/uibase/uiview/viewdlg2.cxx |   11 ++-
 vcl/jsdialog/enabled.cxx |7 +-
 6 files changed, 106 insertions(+), 54 deletions(-)

New commits:
commit 9a0a7ae8f62cc8233b71057caa6bc88c69ee94a1
Author: Skyler Grey 
AuthorDate: Fri Aug 19 12:23:20 2022 +0100
Commit: Szymon Kłos 
CommitDate: Sun Nov 20 15:34:05 2022 +0100

Make the insert caption dialog an async jsdialog

- Using StartExecuteAsync instead of Execute to execute the dialog makes
  it run asyncly
- We need to add a handler for the OK button, otherwise the event won't
  be fired when it's clicked. There seem to be varying names for this
  throughout the codebase, I've chosen OKHdl as it's short, appears to
  be relatively common and fits well with the existing OptionHdl and
  CaptionHdl that the other buttons on the dialog use
- Lastly, we need to enable the JSDialog builder in
  vcl/jsdialog/enabled.cxx so that the dialog becomes a JSDialog

Still TODO:
- Convert the dialogs that open when you press "auto" or "options"
  buttons (will be in a followup review)

Change-Id: Ieabbc4e69c4aa065506f7dc6c823d83e4d784c2f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138313
Reviewed-by: Szymon Kłos 
Tested-by: Jenkins CollaboraOffice 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142988
Tested-by: Jenkins

diff --git a/sw/source/ui/frmdlg/cption.cxx b/sw/source/ui/frmdlg/cption.cxx
index 01ebc9d685c4..8b3c14afe0a6 100644
--- a/sw/source/ui/frmdlg/cption.cxx
+++ b/sw/source/ui/frmdlg/cption.cxx
@@ -138,6 +138,7 @@ SwCaptionDialog::SwCaptionDialog(weld::Window *pParent, 
SwView )
 m_xSepEdit->connect_changed(aLk);
 
 m_xFormatBox->connect_changed(LINK(this, SwCaptionDialog, 
SelectListBoxHdl));
+m_xOKButton->connect_clicked(LINK(this, SwCaptionDialog, OKHdl));
 m_xOptionButton->connect_clicked(LINK(this, SwCaptionDialog, OptionHdl));
 m_xAutoCaptionButton->connect_clicked(LINK(this, SwCaptionDialog, 
CaptionHdl));
 
m_xAutoCaptionButton->set_accessible_description(SwResId(STR_A11Y_DESC_AUTO));
@@ -267,6 +268,12 @@ SwCaptionDialog::SwCaptionDialog(weld::Window *pParent, 
SwView )
 DrawSample();
 }
 
+IMPL_LINK_NOARG(SwCaptionDialog, OKHdl, weld::Button&, void)
+{
+Apply();
+m_xDialog->response(RET_OK);
+}
+
 void SwCaptionDialog::Apply()
 {
 InsCaptionOpt aOpt;
diff --git a/sw/source/uibase/inc/cption.hxx b/sw/source/uibase/inc/cption.hxx
index 0a7bc9ef64c7..5ff685a8cedf 100644
--- a/sw/source/uibase/inc/cption.hxx
+++ b/sw/source/uibase/inc/cption.hxx
@@ -64,6 +64,7 @@ class SwCaptionDialog final : public SfxDialogController
 DECL_LINK(ModifyComboHdl, weld::ComboBox&, void);
 DECL_LINK(OptionHdl, weld::Button&, void);
 DECL_LINK(CaptionHdl, weld::Button&, void);
+DECL_LINK(OKHdl, weld::Button&, void);
 
 void Apply();
 
diff --git a/sw/source/uibase/uiview/viewdlg2.cxx 
b/sw/source/uibase/uiview/viewdlg2.cxx
index eed4eddcc064..19678d38fdcb 100644
--- a/sw/source/uibase/uiview/viewdlg2.cxx
+++ b/sw/source/uibase/uiview/viewdlg2.cxx
@@ -46,15 +46,18 @@
 
 using namespace css;
 
-void SwView::ExecDlgExt(SfxRequest const )
+void SwView::ExecDlgExt(SfxRequest const& rReq)
 {
-switch ( rReq.GetSlot() )
+switch (rReq.GetSlot())
 {
 case FN_INSERT_CAPTION:
 {
 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
-ScopedVclPtr 
pDialog(pFact->CreateSwCaptionDialog(GetFrameWeld(), *this ));
-pDialog->Execute();
+VclPtr pDialog(
+pFact->CreateSwCaptionDialog(GetFrameWeld(), *this));
+pDialog->StartExecuteAsync([pDialog](sal_Int32) {
+pDialog->disposeOnce();
+});
 break;
 }
 case SID_INSERT_SIGNATURELINE:
diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx
index 6923056183af..89b50c96fab1 100644
--- a/vcl/jsdialog/enabled.cxx
+++ b/vcl/jsdialog/enabled.cxx
@@ -69,7 +69,8 @@ bool isBuilderEnabled(std::u16string_view rUIFile, bool 
bMobile)
 || rUIFile == u"sfx/ui/documentpropertiesdialog.ui"
 || rUIFile == u"sfx/ui/custominfopage.ui" || rUIFile == 
u"sfx/ui/cmisinfopage.ui"
 || rUIFile == u"sfx/ui/descriptioninfopage.ui" || rUIFile == 
u"sfx/ui/documentinfopage.ui"
-|| rUIFile == u"sfx/ui/linefragment.ui" || rUIFile == 
u"sfx/ui/editdurationdialog.ui")
+|| rUIFile == u"sfx/ui/linefragment.ui" || rUIFile == 
u"sfx/ui/editdurationdialog.ui"
+|| rUIFile == u"modules/swriter/ui/insertcaption.ui")
 {
 return true;
 }
commit 930b96dee6250eb8d51f25e2e1020bd1e028db03
Author: NickWingate 
AuthorDate: Tue Aug 9 10:54:40 

[Libreoffice-commits] core.git: 2 commits - include/sfx2 sfx2/source sw/source

2020-05-03 Thread Caolán McNamara (via logerrit)
 include/sfx2/styledlg.hxx   |3 ++-
 sfx2/source/dialog/mgetempl.cxx |2 +-
 sfx2/source/dialog/styledlg.cxx |4 ++--
 sw/source/uibase/app/docst.cxx  |2 +-
 4 files changed, 6 insertions(+), 5 deletions(-)

New commits:
commit 00db5933ded1884b2ac453552badae20fa943478
Author: Caolán McNamara 
AuthorDate: Sun May 3 19:46:13 2020 +0100
Commit: Caolán McNamara 
CommitDate: Sun May 3 22:44:21 2020 +0200

use SfxStyleSearchBits::All for GenerateUnusedName

use in SfxManageStyleSheetPage is definitely with
SfxStyleSearchBits::All applied. It seems almost certain that
use in SwDocShell::ExecStyleSheet would prefer that

Change-Id: I245c3f02bcce87f124bf0e507b59738a6dff34d7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93354
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sfx2/source/dialog/styledlg.cxx b/sfx2/source/dialog/styledlg.cxx
index 3f694ec66573..2614083f8f75 100644
--- a/sfx2/source/dialog/styledlg.cxx
+++ b/sfx2/source/dialog/styledlg.cxx
@@ -113,7 +113,7 @@ OUString 
SfxStyleDialogController::GenerateUnusedName(SfxStyleSheetBasePool 
 OUString aNo(SfxResId(STR_NONAME));
 sal_uInt16 i = 1;
 OUString aNoName = aNo + OUString::number(i);
-while (rPool.Find(aNoName, eFam, rPool.GetSearchMask()))
+while (rPool.Find(aNoName, eFam))
 {
 ++i;
 aNoName = aNo + OUString::number(i);
commit a9102a1c637272d88ef542d37b871bd9278cacb7
Author: Caolán McNamara 
AuthorDate: Sun May 3 19:39:19 2020 +0100
Commit: Caolán McNamara 
CommitDate: Sun May 3 22:44:08 2020 +0200

explicitly pass SfxStyleFamily to GenerateUnusedName

Change-Id: I7879578383d58cb65441c9049e91e33bb4827afb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93353
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/include/sfx2/styledlg.hxx b/include/sfx2/styledlg.hxx
index eb91875c5702..6fd7afde1f85 100644
--- a/include/sfx2/styledlg.hxx
+++ b/include/sfx2/styledlg.hxx
@@ -25,6 +25,7 @@
 
 class SfxStyleSheetBase;
 class SfxStyleSheetBasePool;
+enum class SfxStyleFamily;
 
 class SFX2_DLLPUBLIC SfxStyleDialogController : public SfxTabDialogController
 {
@@ -43,7 +44,7 @@ public:
 
 virtual short   Ok() override;
 
-static OUString GenerateUnusedName(SfxStyleSheetBasePool );
+static OUString GenerateUnusedName(SfxStyleSheetBasePool , 
SfxStyleFamily eFam);
 };
 
 #endif
diff --git a/sfx2/source/dialog/mgetempl.cxx b/sfx2/source/dialog/mgetempl.cxx
index f924b41ac96d..44aba7480eaf 100644
--- a/sfx2/source/dialog/mgetempl.cxx
+++ b/sfx2/source/dialog/mgetempl.cxx
@@ -110,7 +110,7 @@ 
SfxManageStyleSheetPage::SfxManageStyleSheetPage(weld::Container* pPage, weld::D
 if ( pStyle->GetName().isEmpty() && pPool )
 {
 // NullString as Name -> generate Name
-OUString aNoName(SfxStyleDialogController::GenerateUnusedName(*pPool));
+OUString aNoName(SfxStyleDialogController::GenerateUnusedName(*pPool, 
pStyle->GetFamily()));
 pStyle->SetName( aNoName );
 aName = aNoName;
 aFollow = pStyle->GetFollow();
diff --git a/sfx2/source/dialog/styledlg.cxx b/sfx2/source/dialog/styledlg.cxx
index 133c338d1176..3f694ec66573 100644
--- a/sfx2/source/dialog/styledlg.cxx
+++ b/sfx2/source/dialog/styledlg.cxx
@@ -108,12 +108,12 @@ IMPL_LINK_NOARG(SfxStyleDialogController, CancelHdl, 
weld::Button&, void)
 m_xDialog->response(RET_CANCEL);
 }
 
-OUString SfxStyleDialogController::GenerateUnusedName(SfxStyleSheetBasePool 
)
+OUString SfxStyleDialogController::GenerateUnusedName(SfxStyleSheetBasePool 
, SfxStyleFamily eFam)
 {
 OUString aNo(SfxResId(STR_NONAME));
 sal_uInt16 i = 1;
 OUString aNoName = aNo + OUString::number(i);
-while (rPool.Find(aNoName, rPool.GetSearchFamily(), rPool.GetSearchMask()))
+while (rPool.Find(aNoName, eFam, rPool.GetSearchMask()))
 {
 ++i;
 aNoName = aNo + OUString::number(i);
diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx
index 70a69a6d255c..72aaf1e8f918 100644
--- a/sw/source/uibase/app/docst.cxx
+++ b/sw/source/uibase/app/docst.cxx
@@ -310,7 +310,7 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq )
 sParent = static_cast(pItem)->GetValue();
 
 if (sName.isEmpty() && m_xBasePool.get())
-sName = 
SfxStyleDialogController::GenerateUnusedName(*m_xBasePool);
+sName = 
SfxStyleDialogController::GenerateUnusedName(*m_xBasePool, nFamily);
 
 Edit(sName, sParent, nFamily, nMask, true, OString(), nullptr, 
, nSlot);
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - include/sfx2 sfx2/source sw/source

2016-03-08 Thread Miklos Vajna
 include/sfx2/classificationhelper.hxx |6 ++
 sfx2/source/view/classificationhelper.cxx |   72 +++---
 sw/source/ui/app/app.src  |5 ++
 sw/source/uibase/dochdl/swdtflvr.cxx  |   25 +-
 sw/source/uibase/inc/app.hrc  |3 -
 5 files changed, 101 insertions(+), 10 deletions(-)

New commits:
commit 32c2a2f8dc04af8a49ad3580af0ea647c45eb877
Author: Miklos Vajna 
Date:   Tue Mar 8 17:58:56 2016 +0100

sw: detect copy between different classification levels

With this we cover all 4 cases of copy between possibly classified
documents. When both are classified, then we also check the
classification level, if they have the same scale.

Change-Id: I8c02781fc9755114cd6a2fb93be11dca7b3441d0

diff --git a/sw/source/ui/app/app.src b/sw/source/ui/app/app.src
index 94b64d7..0b56c96 100644
--- a/sw/source/ui/app/app.src
+++ b/sw/source/ui/app/app.src
@@ -652,4 +652,9 @@ String STR_TARGET_DOC_NOT_CLASSIFIED
 Text [ en-US ] = "This document must be classified before the clipboard 
can be pasted." ;
 };
 
+String STR_DOC_CLASSIFICATION_TOO_LOW
+{
+Text [ en-US ] = "This document has a lower classificaton level than the 
clipboard." ;
+};
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx 
b/sw/source/uibase/dochdl/swdtflvr.cxx
index 84b1af6..04c3ae1 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -3222,13 +3222,34 @@ bool lcl_checkClassification(SwDoc* pSourceDoc, SwDoc* 
pDestinationDoc)
 if (!pSourceShell || !pDestinationShell)
 return true;
 
-// Paste from a classified document to a non-classified one -> deny.
-if (SfxClassificationHelper::IsClassified(*pSourceShell) && 
!SfxClassificationHelper::IsClassified(*pDestinationShell))
+bool bSourceClassified = 
SfxClassificationHelper::IsClassified(*pSourceShell);
+if (!bSourceClassified)
+// No classification on the source side. Return early, regardless the
+// state of the destination side.
+return true;
+
+bool bDestinationClassified = 
SfxClassificationHelper::IsClassified(*pDestinationShell);
+if (bSourceClassified && !bDestinationClassified)
 {
+// Paste from a classified document to a non-classified one -> deny.
 ScopedVclPtrInstance::Create(nullptr, 
SW_RES(STR_TARGET_DOC_NOT_CLASSIFIED), VCL_MESSAGE_INFO)->Execute();
 return false;
 }
 
+// Remaining case: paste between two classified documents.
+SfxClassificationHelper aSource(*pSourceShell);
+SfxClassificationHelper aDestination(*pDestinationShell);
+if (aSource.GetImpactScale() != aDestination.GetImpactScale())
+// It's possible to compare them if they have the same scale.
+return true;
+
+if (aSource.GetImpactLevel() > aDestination.GetImpactLevel())
+{
+// Paste from a doc that has higher classification -> deny.
+ScopedVclPtrInstance::Create(nullptr, 
SW_RES(STR_DOC_CLASSIFICATION_TOO_LOW), VCL_MESSAGE_INFO)->Execute();
+return false;
+}
+
 return true;
 }
 
diff --git a/sw/source/uibase/inc/app.hrc b/sw/source/uibase/inc/app.hrc
index 9962d0c..aab6fd9 100644
--- a/sw/source/uibase/inc/app.hrc
+++ b/sw/source/uibase/inc/app.hrc
@@ -92,8 +92,9 @@
 #define STR_WRONG_TABLENAME (RC_APP_BEGIN + 138)
 #define STR_SRTERR  (RC_APP_BEGIN + 139)
 #define STR_TARGET_DOC_NOT_CLASSIFIED   (RC_APP_BEGIN + 140)
+#define STR_DOC_CLASSIFICATION_TOO_LOW  (RC_APP_BEGIN + 141)
 
-#define APP_ACT_END STR_TARGET_DOC_NOT_CLASSIFIED
+#define APP_ACT_END STR_DOC_CLASSIFICATION_TOO_LOW
 
 #if APP_ACT_END > RC_APP_END
 #error Resource-Id Ueberlauf in #file, #line
commit 740a72e66ddf3efd4028d8268239f9a50f759499
Author: Miklos Vajna 
Date:   Tue Mar 8 14:29:15 2016 +0100

sfx2 classification: expose impact scale and level

This allows application code to prevent copypaste from a more
confidential to a less confidential document.

Change-Id: I121c7566c948340e7b41d3f8462b0d65a2441b0f

diff --git a/include/sfx2/classificationhelper.hxx 
b/include/sfx2/classificationhelper.hxx
index 5b007020..5c49db7 100644
--- a/include/sfx2/classificationhelper.hxx
+++ b/include/sfx2/classificationhelper.hxx
@@ -40,9 +40,13 @@ public:
 std::vector GetBACNames();
 /// Setting this sets all the other properties, based on the policy.
 void SetBACName(const OUString& rName);
-/// If GetImpactLevelColor() will return something meaningful.
+/// If GetImpactScale() and GetImpactLevel*() will return something 
meaningful.
 bool HasImpactLevel();
 basegfx::BColor GetImpactLevelColor();
+/// Larger value means more confidential.
+sal_Int32 GetImpactLevel();
+/// Comparing the GetImpactLevel() result is only 

[Libreoffice-commits] core.git: 2 commits - include/sfx2 sfx2/source sw/source

2013-07-23 Thread Noel Grandin
 include/sfx2/sfxuno.hxx |5 -
 sfx2/source/bastyp/mieclip.cxx  |2 +-
 sfx2/source/bastyp/sfxhtml.cxx  |2 +-
 sfx2/source/control/shell.cxx   |2 +-
 sw/source/core/unocore/unodraw.cxx  |2 +-
 sw/source/core/unocore/unoframe.cxx |2 +-
 sw/source/core/unocore/unotext.cxx  |2 +-
 sw/source/ui/utlui/unotools.cxx |9 -
 8 files changed, 14 insertions(+), 12 deletions(-)

New commits:
commit d8fa15f0ea3bbf38f5142f83121b7c72c483c7f5
Author: Noel Grandin n...@peralex.com
Date:   Tue Jul 23 14:55:38 2013 +0200

fdo#67213 - crash on opening AutoText dialog (Ctrl+F3)

I created this bug with commit
32eaa77db33b3b1f5793e92167b9f8c2708ea543
fdo#46808, Convert frame::FrameControl service to new style

If we cannot create a css::frame::FrameControl service, just continue.

Change-Id: Iffd6952fd5153af5a1ab72af2bc55864816a750d

diff --git a/sw/source/ui/utlui/unotools.cxx b/sw/source/ui/utlui/unotools.cxx
index 62fadcc..64d97c9 100644
--- a/sw/source/ui/utlui/unotools.cxx
+++ b/sw/source/ui/utlui/unotools.cxx
@@ -112,7 +112,14 @@ void SwOneExampleFrame::CreateControl()
 uno::Reference lang::XMultiServiceFactory 
 xMgr = 
comphelper::getProcessServiceFactory();
 uno::Reference uno::XComponentContext  xContext = 
comphelper::getProcessComponentContext();
-m_xFrameControl = frame::FrameControl::create(xContext);
+try
+{
+m_xFrameControl = frame::FrameControl::create(xContext);
+}
+catch ( css::uno::DeploymentException )
+{
+return;
+}
 
 uno::Reference awt::XWindowPeer   xParent( 
aTopWindow.GetComponentInterface() );
 
commit 312f3aac56b410021bdf3db70d36b7fe88b3744f
Author: Noel Grandin n...@peralex.com
Date:   Tue Jul 23 14:32:10 2013 +0200

expand out the U2S and S2U macros from sfxuno.hxx

They are vestiges of the old string classes.

Change-Id: I5dd458bd2dac5f2e867ddaa731190f159b8a3b65

diff --git a/include/sfx2/sfxuno.hxx b/include/sfx2/sfxuno.hxx
index 3dee2ba..cab9200 100644
--- a/include/sfx2/sfxuno.hxx
+++ b/include/sfx2/sfxuno.hxx
@@ -66,11 +66,6 @@ bool GetEncryptionData_Impl( const SfxItemSet* pSet, 
css::uno::Sequence css::be
 
 #define FrameSearchFlagssal_Int32
 
-// Macros to convert string - unicode and unicode - string.
-// We use UTF8 everytime. Its the best way to do this!
-#define S2U(STRING) OStringToOUString(STRING, 
RTL_TEXTENCODING_UTF8)
-#define U2S(STRING) OUStringToOString(STRING, 
RTL_TEXTENCODING_UTF8)
-
 
//
 //  macros for declaration and definition of uno-services
 
//
diff --git a/sfx2/source/bastyp/mieclip.cxx b/sfx2/source/bastyp/mieclip.cxx
index 71776fd..45404d8 100644
--- a/sfx2/source/bastyp/mieclip.cxx
+++ b/sfx2/source/bastyp/mieclip.cxx
@@ -60,7 +60,7 @@ SvStream* MSE40HTMLClipFormatObj::IsValid( SvStream rStream )
 else if (sTmp.equalsL(RTL_CONSTASCII_STRINGPARAM(EndFragment)))
 nFragEnd = sLine.copy(nIndex).toInt32();
 else if (sTmp.equalsL(RTL_CONSTASCII_STRINGPARAM(SourceURL)))
-sBaseURL = S2U(sLine.copy(nIndex));
+sBaseURL = OStringToOUString( sLine.copy(nIndex), 
RTL_TEXTENCODING_UTF8 );
 
 if (nEnd = 0  nStt = 0 
 (sBaseURL.Len() || rStream.Tell() = 
static_castsal_Size(nStt)))
diff --git a/sfx2/source/bastyp/sfxhtml.cxx b/sfx2/source/bastyp/sfxhtml.cxx
index bbbd5de..e45fcc1 100644
--- a/sfx2/source/bastyp/sfxhtml.cxx
+++ b/sfx2/source/bastyp/sfxhtml.cxx
@@ -255,7 +255,7 @@ sal_Bool SfxHTMLParser::FinishFileDownload( String rStr )
 
 aStream.Seek( 0 );
 OString sBuffer = read_uInt8s_ToOString(aStream, nLen);
-rStr = S2U(sBuffer);
+rStr = OStringToOUString( sBuffer, RTL_TEXTENCODING_UTF8 );
 }
 
 delete pDLMedium;
diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx
index 5542998..4f8b945 100644
--- a/sfx2/source/control/shell.cxx
+++ b/sfx2/source/control/shell.cxx
@@ -992,7 +992,7 @@ void SfxShell::SetVerbs(const com::sun::star::uno::Sequence 
 com::sun::star::em
 pNewSlot-fnExec = SFX_STUB_PTR(SfxShell,VerbExec);
 pNewSlot-fnState = SFX_STUB_PTR(SfxShell,VerbState);
 pNewSlot-pType = 0; // HACK(SFX_TYPE(SfxVoidItem)) ???
-pNewSlot-pName = U2S(aVerbs[n].VerbName).getStr();
+pNewSlot-pName = OUStringToOString( aVerbs[n].VerbName, 
RTL_TEXTENCODING_UTF8 ).getStr();
 pNewSlot-pLinkedSlot = 0;
 pNewSlot-nArgDefCount = 0;
 pNewSlot-pFirstArgDef = 0;
diff --git a/sw/source/core/unocore/unodraw.cxx 
b/sw/source/core/unocore/unodraw.cxx
index