[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - 3 commits - desktop/qa desktop/source officecfg/registry sfx2/sdi sw/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 19 07:34:33 UTC 2019


 desktop/qa/desktop_lib/test_desktop_lib.cxx                |   18 +++++++++++++
 desktop/source/lib/init.cxx                                |    1 
 officecfg/registry/schema/org/openoffice/Office/Writer.xcs |   12 ++++++++
 sfx2/sdi/sfx.sdi                                           |    2 -
 sw/source/filter/html/swhtml.cxx                           |    5 +++
 sw/source/filter/html/swhtml.hxx                           |    2 -
 sw/source/uibase/dochdl/swdtflvr.cxx                       |   15 +++++++---
 sw/source/uibase/inc/swdtflvr.hxx                          |    7 ++---
 sw/source/uibase/shells/basesh.cxx                         |   10 +++++--
 9 files changed, 59 insertions(+), 13 deletions(-)

New commits:
commit 8ec5bdd071fd273c5bc59ed11cdd65642dadd86e
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue May 28 09:25:17 2019 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Jun 19 09:24:17 2019 +0200

    [cp] sw HTML import: change config default to always ignore comments
    
    Change-Id: Iae6191fbcf1d02e9e5dd29613eaf5c36646afccc
    Reviewed-on: https://gerrit.libreoffice.org/73084
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
index bc1d0c0b076d..40a48cd28e21 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
@@ -5873,7 +5873,7 @@
               <desc>Specifies whether HTML comments should be ignored or imported as postits / annotations.</desc>
               <label>Ignore HTML comments</label>
             </info>
-            <value>false</value>
+            <value>true</value>
           </prop>
         </group>
       </group>
commit af34be1ba54aee946d72db1ccddb8a3bf74ac533
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon May 27 10:46:40 2019 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Jun 19 09:24:17 2019 +0200

    sw HTML import: add an option to ignore comments by default
    
    No function change, default behavior is still mapping them to postits.
    
    Change-Id: I55041452909e9f0b83d6c5d113af3067b3c0afdb
    Reviewed-on: https://gerrit.libreoffice.org/73021
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins
    (cherry picked from commit 256107622c252afdce35d1c77fe70eb4e4bc57ce)

diff --git a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
index a5e6a121b03b..bc1d0c0b076d 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
@@ -5864,6 +5864,18 @@
             <value>true</value>
           </prop>
         </group>
+        <group oor:name="HTML">
+          <info>
+            <desc>Contains settings for importing HTML.</desc>
+          </info>
+          <prop oor:name="IgnoreComments" oor:type="xs:boolean" oor:nillable="false">
+            <info>
+              <desc>Specifies whether HTML comments should be ignored or imported as postits / annotations.</desc>
+              <label>Ignore HTML comments</label>
+            </info>
+            <value>false</value>
+          </prop>
+        </group>
       </group>
     </group>
     <group oor:name="Numbering">
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index ce6a79f8e0dd..daa5002b684c 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -116,6 +116,7 @@
 
 #include <sfx2/viewfrm.hxx>
 #include <svx/svdobj.hxx>
+#include <officecfg/Office/Writer.hxx>
 
 #include <swerror.h>
 #include <hints.hxx>
@@ -312,6 +313,10 @@ SwHTMLParser::SwHTMLParser( SwDoc* pD, SwPaM& rCursor, SvStream& rIn,
     m_nTableDepth( 0 ),
     m_pTempViewFrame(nullptr)
 {
+    // If requested explicitly, then force ignoring of comments (don't create postits for them).
+    if (officecfg::Office::Writer::Filter::Import::HTML::IgnoreComments::get())
+        m_bIgnoreHTMLComments = true;
+
     m_nEventId = nullptr;
     m_bUpperSpace = m_bViewCreated = m_bChkJumpMark = false;
 
diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx
index 5c633f326964..c0f3523f4303 100644
--- a/sw/source/filter/html/swhtml.hxx
+++ b/sw/source/filter/html/swhtml.hxx
@@ -448,7 +448,7 @@ class SwHTMLParser : public SfxHTMLParser, public SwClient
     bool m_bSelect : 1;
     bool m_bInFootEndNoteAnchor : 1;
     bool m_bInFootEndNoteSymbol : 1;
-    bool const m_bIgnoreHTMLComments : 1;
+    bool m_bIgnoreHTMLComments : 1;
     bool m_bRemoveHidden : 1; // the filter implementation might set the hidden flag
 
     bool m_bBodySeen : 1;
commit ce3a5865da236c25c855a1ca0392a386c8560231
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu May 23 11:53:26 2019 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Jun 19 09:24:17 2019 +0200

    sw: add IgnoreComments parameter to .uno:Paste
    
    Which allows not hardcoding true for LOK.
    
    Conflicts:
            sw/source/uibase/dochdl/swdtflvr.cxx
            sw/source/uibase/inc/swdtflvr.hxx
    
    Reviewed-on: https://gerrit.libreoffice.org/72833
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>
    
    Conflicts:
            desktop/qa/desktop_lib/test_desktop_lib.cxx
    
    Change-Id: I644763ba052b148fc34283e361aa02f9bba2c5ee

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 855bb398a570..129eef6797bc 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -550,6 +550,24 @@ void DesktopLOKTest::testPasteWriter()
     // Writer is expected to support text/html.
     CPPUNIT_ASSERT(pDocument->pClass->paste(pDocument, "text/html", aText.getStr(), aText.getLength()));
 
+    // Overwrite doc contents with a HTML paste.
+    pDocument->pClass->postUnoCommand(pDocument, ".uno:SelectAll", nullptr, false);
+    Scheduler::ProcessEventsToIdle();
+    OString aComment("foo <!-- bar --> baz");
+    CPPUNIT_ASSERT(pDocument->pClass->paste(pDocument, "text/html", aComment.getStr(), aComment.getLength()));
+
+    // Check if we have a comment.
+    uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XEnumerationAccess> xParagraphEnumerationAccess(xTextDocument->getText(), uno::UNO_QUERY);
+    uno::Reference<container::XEnumeration> xParagraphEnumeration = xParagraphEnumerationAccess->createEnumeration();
+    uno::Reference<container::XEnumerationAccess> xParagraph(xParagraphEnumeration->nextElement(), uno::UNO_QUERY);
+    uno::Reference<container::XEnumeration> xTextPortionEnumeration = xParagraph->createEnumeration();
+    uno::Reference<beans::XPropertySet> xTextPortion(xTextPortionEnumeration->nextElement(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(OUString("Text"), xTextPortion->getPropertyValue("TextPortionType").get<OUString>());
+    // Without the accompanying fix in place, this test would have failed, as we had a comment
+    // between "foo" and "baz".
+    CPPUNIT_ASSERT(!xTextPortionEnumeration->hasMoreElements());
+
     comphelper::LibreOfficeKit::setActive(false);
 }
 
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 4964859eb664..1ea6dd95eb03 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2805,6 +2805,7 @@ static bool doc_paste(LibreOfficeKitDocument* pThis, const char* pMimeType, cons
     uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
     {
         {"AnchorType", uno::makeAny(static_cast<sal_uInt16>(text::TextContentAnchorType_AS_CHARACTER))},
+        {"IgnoreComments", uno::makeAny(true)},
     }));
     if (!comphelper::dispatchCommand(".uno:Paste", aPropertyValues))
     {
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 56d59c0053d0..2540782a7427 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -3022,7 +3022,7 @@ SfxTemplateItem ParaStyle SID_STYLE_FAMILY2
 
 
 SfxVoidItem Paste SID_PASTE
-(SfxUInt16Item AnchorType FN_PARAM_1)
+(SfxUInt16Item AnchorType FN_PARAM_1, SfxBoolItem IgnoreComments FN_PARAM_2)
 [
     AutoUpdate = FALSE,
     FastCall = TRUE,
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index 33497fafbef4..3a66f220af05 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -1112,7 +1112,7 @@ bool SwTransferable::IsPaste( const SwWrtShell& rSh,
     return bIsPaste;
 }
 
-bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndStdIds nAnchorType)
+bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndStdIds nAnchorType, bool bIgnoreComments)
 {
     sal_uInt8 nEventAction, nAction=0;
     SotExchangeDest nDestination = SwTransferable::GetSotDestination( rSh );
@@ -1204,7 +1204,7 @@ bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndSt
 
     return EXCHG_INOUT_ACTION_NONE != nAction &&
             SwTransferable::PasteData( rData, rSh, nAction, nActionFlags, nFormat,
-                                        nDestination, false, false, nullptr, 0, false, nAnchorType );
+                                        nDestination, false, false, nullptr, 0, false, nAnchorType, bIgnoreComments );
 }
 
 bool SwTransferable::PasteData( TransferableDataHelper& rData,
@@ -1213,7 +1213,8 @@ bool SwTransferable::PasteData( TransferableDataHelper& rData,
                             SotExchangeDest nDestination, bool bIsPasteFormat,
                             bool bIsDefault,
                             const Point* pPt, sal_Int8 nDropAction,
-                            bool bPasteSelection, RndStdIds nAnchorType )
+                            bool bPasteSelection, RndStdIds nAnchorType,
+                            bool bIgnoreComments)
 {
     SwWait aWait( *rSh.GetView().GetDocShell(), false );
     std::unique_ptr<SwTrnsfrActionAndUndo, o3tl::default_delete<SwTrnsfrActionAndUndo>> pAction;
@@ -1367,7 +1368,7 @@ bool SwTransferable::PasteData( TransferableDataHelper& rData,
             case SotClipboardFormatId::RICHTEXT:
             case SotClipboardFormatId::STRING:
                 bRet = SwTransferable::PasteFileContent( rData, rSh,
-                                                            nFormat, bMsg );
+                                                            nFormat, bMsg, bIgnoreComments );
                 break;
 
             case SotClipboardFormatId::NETSCAPE_BOOKMARK:
@@ -1647,7 +1648,7 @@ SotExchangeDest SwTransferable::GetSotDestination( const SwWrtShell& rSh )
 }
 
 bool SwTransferable::PasteFileContent( TransferableDataHelper& rData,
-                                    SwWrtShell& rSh, SotClipboardFormatId nFormat, bool bMsg )
+                                    SwWrtShell& rSh, SotClipboardFormatId nFormat, bool bMsg, bool bIgnoreComments )
 {
     const char* pResId = STR_CLPBRD_FORMAT_ERROR;
     bool bRet = false;
@@ -1719,6 +1720,10 @@ bool SwTransferable::PasteFileContent( TransferableDataHelper& rData,
         const SwPosition& rInsPos = *rSh.GetCursor()->Start();
         SwReader aReader( *pStream, aEmptyOUStr, OUString(), *rSh.GetCursor() );
         rSh.SaveTableBoxContent( &rInsPos );
+
+        if (bIgnoreComments)
+            pRead->SetIgnoreHTMLComments(true);
+
         if( aReader.Read( *pRead ).IsError() )
             pResId = STR_ERROR_CLPBRD_READ;
         else
diff --git a/sw/source/uibase/inc/swdtflvr.hxx b/sw/source/uibase/inc/swdtflvr.hxx
index f9dc71623477..5c5777ef3847 100644
--- a/sw/source/uibase/inc/swdtflvr.hxx
+++ b/sw/source/uibase/inc/swdtflvr.hxx
@@ -96,7 +96,7 @@ class SW_DLLPUBLIC SwTransferable : public TransferableHelper
                                         SotClipboardFormatId nFormat, SotExchangeDest nDestination );
 
     static bool PasteFileContent( TransferableDataHelper&,
-                                    SwWrtShell& rSh, SotClipboardFormatId nFormat, bool bMsg );
+                                    SwWrtShell& rSh, SotClipboardFormatId nFormat, bool bMsg, bool bIgnoreComments = false );
     static bool PasteOLE( TransferableDataHelper& rData, SwWrtShell& rSh,
                             SotClipboardFormatId nFormat, SotExchangeActionFlags nActionFlags, bool bMsg );
     static bool PasteTargetURL( TransferableDataHelper& rData, SwWrtShell& rSh,
@@ -174,14 +174,15 @@ public:
 
     // paste - methods and helper methods for the paste
     static bool IsPaste( const SwWrtShell&, const TransferableDataHelper& );
-    static bool Paste( SwWrtShell&, TransferableDataHelper&, RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA );
+    static bool Paste( SwWrtShell&, TransferableDataHelper&, RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA, bool bIgnoreComments = false );
     static bool PasteData( TransferableDataHelper& rData,
                           SwWrtShell& rSh, sal_uInt8 nAction, SotExchangeActionFlags nActionFlags,
                           SotClipboardFormatId nFormat,
                           SotExchangeDest nDestination, bool bIsPasteFormat,
                           bool bIsDefault,
                           const Point* pDDPos = nullptr, sal_Int8 nDropAction = 0,
-                          bool bPasteSelection = false, RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA );
+                          bool bPasteSelection = false, RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA,
+                          bool bIgnoreComments = false );
 
     static bool IsPasteSpecial( const SwWrtShell& rWrtShell,
                                 const TransferableDataHelper& );
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx
index 84cce3758271..1b885e9a635f 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -284,11 +284,15 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq)
                     // destroyed after the paste.
                     SwView* pView = &rView;
 
+                    RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA;
                     const SfxUInt16Item* pAnchorType = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1);
                     if (pAnchorType)
-                        SwTransferable::Paste(rSh, aDataHelper, static_cast<RndStdIds>(pAnchorType->GetValue()));
-                    else
-                        SwTransferable::Paste(rSh, aDataHelper);
+                        nAnchorType = static_cast<RndStdIds>(pAnchorType->GetValue());
+                    bool bIgnoreComments = false;
+                    const SfxBoolItem* pIgnoreComments = rReq.GetArg<SfxBoolItem>(FN_PARAM_2);
+                    if (pIgnoreComments)
+                        bIgnoreComments = pIgnoreComments->GetValue();
+                    SwTransferable::Paste(rSh, aDataHelper, nAnchorType, bIgnoreComments);
 
                     if( rSh.IsFrameSelected() || rSh.IsObjSelected() )
                         rSh.EnterSelFrameMode();


More information about the Libreoffice-commits mailing list