[Libreoffice-commits] core.git: 2 commits - sw/qa sw/source writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Mon Jul 27 00:24:00 PDT 2015


 sw/qa/extras/uiwriter/uiwriter.cxx                        |   42 ++++++++++++++
 sw/source/core/doc/DocumentLinksAdministrationManager.cxx |    3 -
 writerfilter/source/dmapper/DomainMapper.cxx              |    8 +-
 writerfilter/source/dmapper/DomainMapper.hxx              |    6 +-
 4 files changed, 49 insertions(+), 10 deletions(-)

New commits:
commit 6d77d7db8704327071b3d46508310c8453cf1cd1
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Jul 27 09:22:10 2015 +0200

    writerfilter: use std::unique_ptr<> in DomainMapper
    
    Change-Id: I569add9792d533bd3bcda5d5cb4023b37bd3f1ed

diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 6a4a85a..25c3cd5 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -189,8 +189,6 @@ DomainMapper::~DomainMapper()
         (void)rEx;
     }
 
-    delete m_pImpl;
-
 #ifdef DEBUG_WRITERFILTER
         TagLogger::getInstance().endDocument();
 #endif
@@ -1092,7 +1090,7 @@ sal_Int32 lcl_getCurrentNumberingProperty(
 }
 
 // In rtl-paragraphs the meaning of left/right are to be exchanged
-static bool ExchangeLeftRight(const PropertyMapPtr& rContext, DomainMapper_Impl* m_pImpl)
+static bool ExchangeLeftRight(const PropertyMapPtr& rContext, DomainMapper_Impl& rImpl)
 {
     bool bExchangeLeftRight = false;
     boost::optional<PropertyMap::Property> aPropPara = rContext->getProperty(PROP_WRITING_MODE);
@@ -1105,7 +1103,7 @@ static bool ExchangeLeftRight(const PropertyMapPtr& rContext, DomainMapper_Impl*
     else
     {
         // check if there RTL <bidi> in default style for the paragraph
-        StyleSheetEntryPtr pTable = m_pImpl->GetStyleSheetTable()->FindDefaultParaStyle();
+        StyleSheetEntryPtr pTable = rImpl.GetStyleSheetTable()->FindDefaultParaStyle();
         if ( pTable )
         {
             boost::optional<PropertyMap::Property> aPropStyle = pTable->pProperties->getProperty(PROP_WRITING_MODE);
@@ -1170,7 +1168,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
     switch(nSprmId)
     {
     case NS_ooxml::LN_CT_PPrBase_jc:
-        handleParaJustification(nIntValue, rContext, ExchangeLeftRight( rContext, m_pImpl ));
+        handleParaJustification(nIntValue, rContext, ExchangeLeftRight( rContext, *m_pImpl ));
         break;
     case NS_ooxml::LN_CT_PPrBase_keepLines:
         rContext->Insert(PROP_PARA_SPLIT, uno::makeAny(nIntValue == 0));
diff --git a/writerfilter/source/dmapper/DomainMapper.hxx b/writerfilter/source/dmapper/DomainMapper.hxx
index 0e30f22..0cd2878 100644
--- a/writerfilter/source/dmapper/DomainMapper.hxx
+++ b/writerfilter/source/dmapper/DomainMapper.hxx
@@ -26,7 +26,7 @@
 
 #include <map>
 #include <vector>
-#include <boost/scoped_ptr.hpp>
+#include <memory>
 
 namespace com{ namespace sun {namespace star{
     namespace beans{
@@ -72,7 +72,7 @@ enum SprmType
 class DomainMapper : public LoggedProperties, public LoggedTable,
                     public BinaryObj, public LoggedStream
 {
-    DomainMapper_Impl   *m_pImpl;
+    std::unique_ptr<DomainMapper_Impl> m_pImpl;
 
 public:
     DomainMapper(const css::uno::Reference<css::uno::XComponentContext>& xContext,
@@ -169,7 +169,7 @@ private:
     static css::style::TabAlign getTabAlignFromValue(const sal_Int32 nIntValue);
     static sal_Unicode getFillCharFromValue(const sal_Int32 nIntValue);
     bool mbIsSplitPara;
-    boost::scoped_ptr< GraphicZOrderHelper > zOrderHelper;
+    std::unique_ptr< GraphicZOrderHelper > zOrderHelper;
 };
 
 } // namespace dmapper
commit e06e2cb18874987d2dafd4faa0a8b71fc0aa6453
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Jul 27 09:16:16 2015 +0200

    tdf#90575 sw: fix pasting DDE links
    
    Regression from commit 0761f81643a6890457e9ef7d913ab5c88c2593a4 (123792:
    complete annotations on text ranges feature, 2013-12-19), the problem
    was that the added additional IDocumentMarkAccess::GetType() check in
    lcl_FindDdeBookmark(), which means that the function no longer finds
    bookmarks with the matching name, only real DDE marks. This is a
    problem, as SwTrnsfrDdeLink::WriteData() depends on the fact that
    sw::mark::Bookmark inherits from sw::mark::DdeBookmark. As a result, the
    fast IDocumentMarkAccess::GetType() (that intentionally doesn't handle
    inheritance for performance reasons) can't be used here.
    
    Change-Id: I2b7a07c18b641ac991f3227812a609dedc960e08

diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 16bd01f..ebac88b 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -10,6 +10,7 @@
 #include <com/sun/star/awt/FontWeight.hpp>
 #include <com/sun/star/drawing/GraphicExportFilter.hpp>
 #include <com/sun/star/i18n/TextConversionOption.hpp>
+#include <com/sun/star/frame/DispatchHelper.hpp>
 #include <swmodeltestbase.hxx>
 #include <ndtxt.hxx>
 #include <wrtsh.hxx>
@@ -66,6 +67,7 @@
 #include "com/sun/star/text/XTextField.hpp"
 #include "com/sun/star/text/TextMarkupType.hpp"
 #include <osl/file.hxx>
+#include <comphelper/propertysequence.hxx>
 
 static const char* DATA_DIRECTORY = "/sw/qa/extras/uiwriter/data/";
 
@@ -133,6 +135,7 @@ public:
     void testUnoCursorPointer();
     void testTextTableCellNames();
     void testShapeAnchorUndo();
+    void testDde();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest);
     CPPUNIT_TEST(testReplaceForward);
@@ -193,6 +196,7 @@ public:
     CPPUNIT_TEST(testUnoCursorPointer);
     CPPUNIT_TEST(testTextTableCellNames);
     CPPUNIT_TEST(testShapeAnchorUndo);
+    CPPUNIT_TEST(testDde);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1999,6 +2003,44 @@ void SwUiWriterTest::testShapeAnchorUndo()
     CPPUNIT_ASSERT(aOrigLogicRect == pObject->GetLogicRect());
 }
 
+void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, const OUString& rCommand, const uno::Sequence<beans::PropertyValue>& rPropertyValues)
+{
+    uno::Reference<frame::XController> xController = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY)->getCurrentController();
+    CPPUNIT_ASSERT(xController.is());
+    uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xFrame.is());
+
+    uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
+    uno::Reference<frame::XDispatchHelper> xDispatchHelper(frame::DispatchHelper::create(xContext));
+    CPPUNIT_ASSERT(xDispatchHelper.is());
+
+    xDispatchHelper->executeDispatch(xFrame, rCommand, OUString(), 0, rPropertyValues);
+}
+
+void SwUiWriterTest::testDde()
+{
+    // Type asdf and copy it.
+    SwDoc* pDoc = createDoc();
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+    pWrtShell->Insert("asdf");
+    pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 4, /*bBasicCall=*/false);
+    uno::Sequence<beans::PropertyValue> aPropertyValues;
+    lcl_dispatchCommand(mxComponent, ".uno:Copy", aPropertyValues);
+
+    // Go before the selection and paste as a DDE link.
+    pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false);
+    aPropertyValues = comphelper::InitPropertySequence(
+    {
+        {"SelectedFormat", uno::makeAny(static_cast<sal_uInt32>(SotClipboardFormatId::LINK))}
+    });
+    lcl_dispatchCommand(mxComponent, ".uno:ClipboardFormatItems", aPropertyValues);
+
+    // Make sure that the document starts with a field now, and its expanded string value contains asdf.
+    const uno::Reference< text::XTextRange > xField = getRun(getParagraph(1), 1);
+    CPPUNIT_ASSERT_EQUAL(OUString("TextField"), getProperty<OUString>(xField, "TextPortionType"));
+    CPPUNIT_ASSERT(xField->getString().endsWith("asdf"));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
index 36f5519..cb872c4 100644
--- a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
+++ b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
@@ -95,9 +95,8 @@ namespace
             ppMark != rMarkAccess.getAllMarksEnd();
             ++ppMark)
         {
-            if ( IDocumentMarkAccess::GetType( *(ppMark->get()) ) == IDocumentMarkAccess::MarkType::DDE_BOOKMARK)
+            if (::sw::mark::DdeBookmark* const pBkmk = dynamic_cast< ::sw::mark::DdeBookmark*>(ppMark->get()))
             {
-                ::sw::mark::DdeBookmark* const pBkmk = dynamic_cast< ::sw::mark::DdeBookmark*>(ppMark->get());
                 if (!pBkmk)
                     return NULL;
                 if (


More information about the Libreoffice-commits mailing list