[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/inc sw/Library_sw.mk sw/README sw/source

Szymon Kłos szymon.klos at collabora.com
Thu May 4 11:13:58 UTC 2017


 sw/Library_sw.mk                       |    1 
 sw/README                              |    1 
 sw/inc/iodetect.hxx                    |    2 +
 sw/source/filter/basflt/fltini.cxx     |   21 ++++++++++++-
 sw/source/filter/basflt/iodetect.cxx   |    3 +
 sw/source/filter/docx/swdocxreader.cxx |   51 +++++++++++++++++++++++++++++++++
 sw/source/filter/docx/swdocxreader.hxx |   40 +++++++++++++++++++++++++
 sw/source/ui/misc/glossary.cxx         |    6 +++
 8 files changed, 122 insertions(+), 3 deletions(-)

New commits:
commit 7cd9ad5fe40ee10aba7ae030e4fc350da9491044
Author: Szymon Kłos <szymon.klos at collabora.com>
Date:   Fri Apr 14 10:22:37 2017 +0200

    AutoText: .dotx files visible when import
    
    Change-Id: Idd2cdd9696a15ca5a215fc42b46cc470c4c25a28
    Reviewed-on: https://gerrit.libreoffice.org/36550
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
    Tested-by: Szymon Kłos <szymon.klos at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/37231

diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 811c8c629ef6..b49e6f6fe415 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -500,6 +500,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
     sw/source/filter/basflt/fltshell \
     sw/source/filter/basflt/iodetect \
     sw/source/filter/basflt/shellio \
+    sw/source/filter/docx/swdocxreader \
     sw/source/filter/html/SwAppletImpl \
     sw/source/filter/html/css1atr \
     sw/source/filter/html/css1kywd \
diff --git a/sw/README b/sw/README
index dc1e02d99639..440852b30323 100644
--- a/sw/README
+++ b/sw/README
@@ -17,6 +17,7 @@ comments show that Writer core dates back until at least November
  * filter: Writer internal filters
    * ascii: plan text filter
    * basflt
+   * docx: wrapper for the UNO DOCX import filter (in writerfilter) for autotext purposes
    * html: HTML filter
    * inc: include files for filters
    * rtf: thin copy&paste helper around the UNO RTF import filter (in writerfilter)
diff --git a/sw/inc/iodetect.hxx b/sw/inc/iodetect.hxx
index cce9b3225095..290d1c1a2ccd 100644
--- a/sw/inc/iodetect.hxx
+++ b/sw/inc/iodetect.hxx
@@ -36,6 +36,7 @@
 #define FILTER_XML      "CXML"      ///< XML filter
 #define FILTER_XMLV     "CXMLV"     ///< XML filter
 #define FILTER_XMLVW    "CXMLVWEB"  ///< XML filter
+#define FILTER_DOCX     "OXML"
 #define sHTML           "HTML"
 #define sWW5            "WW6"
 #define sWW6            "CWW6"
@@ -69,6 +70,7 @@ enum ReaderWriterEnum {
     READER_WRITER_XML,
     READER_WRITER_TEXT_DLG,
     READER_WRITER_TEXT,
+    READER_WRITER_DOCX,
     MAXFILTER
 };
 
diff --git a/sw/source/filter/basflt/fltini.cxx b/sw/source/filter/basflt/fltini.cxx
index 071751bd7006..af368df364a0 100644
--- a/sw/source/filter/basflt/fltini.cxx
+++ b/sw/source/filter/basflt/fltini.cxx
@@ -66,9 +66,10 @@ SwRead ReadAscii = nullptr, ReadHTML = nullptr, ReadXML = nullptr;
 
 Reader* GetRTFReader();
 Reader* GetWW8Reader();
+Reader* GetDOCXReader();
 
 // Note: if editing, please don't forget to modify also the enum
-// ReaderWriterEnum and aFilterDetect in shellio.hxx
+// ReaderWriterEnum and aFilterDetect in iodetect.hxx & iodetect.cxx
 SwReaderWriterEntry aReaderWriter[] =
 {
     SwReaderWriterEntry( &::GetRTFReader, &::GetRTFWriter,  true  ),
@@ -80,7 +81,8 @@ SwReaderWriterEntry aReaderWriter[] =
     SwReaderWriterEntry( &::GetWW8Reader, nullptr,                true  ),
     SwReaderWriterEntry( nullptr,               &::GetXMLWriter,  true  ),
     SwReaderWriterEntry( nullptr,               &::GetASCWriter,  false ),
-    SwReaderWriterEntry( nullptr,               &::GetASCWriter,  true  )
+    SwReaderWriterEntry( nullptr,               &::GetASCWriter,  true  ),
+    SwReaderWriterEntry( &::GetDOCXReader,      nullptr,          true  )
 };
 
 Reader* SwReaderWriterEntry::GetReader()
@@ -643,6 +645,7 @@ extern "C" {
     void ExportRTF( const OUString&, const OUString& rBaseURL, WriterRef& );
     Reader *ImportDOC();
     void ExportDOC( const OUString&, const OUString& rBaseURL, WriterRef& );
+    Reader *ImportDOCX();
     sal_uLong SaveOrDelMSVBAStorage_ww8( SfxObjectShell&, SotStorage&, sal_Bool, const OUString& );
     sal_uLong GetSaveWarningOfMSVBAStorage_ww8( SfxObjectShell& );
 }
@@ -707,6 +710,20 @@ void GetWW8Writer( const OUString& rFltName, const OUString& rBaseURL, WriterRef
 #endif
 }
 
+Reader* GetDOCXReader()
+{
+#ifndef DISABLE_DYNLOADING
+    FnGetReader pFunction = reinterpret_cast<FnGetReader>( SwGlobals::getFilters().GetMswordLibSymbol( "ImportDOCX" ) );
+
+    if ( pFunction )
+        return (*pFunction)();
+
+    return nullptr;
+#else
+    return ImportDOCX();
+#endif
+}
+
 typedef sal_uLong ( SAL_CALL *SaveOrDel )( SfxObjectShell&, SotStorage&, sal_Bool, const OUString& );
 typedef sal_uLong ( SAL_CALL *GetSaveWarning )( SfxObjectShell& );
 
diff --git a/sw/source/filter/basflt/iodetect.cxx b/sw/source/filter/basflt/iodetect.cxx
index 5b6e92ff8a91..10c41162fbfc 100644
--- a/sw/source/filter/basflt/iodetect.cxx
+++ b/sw/source/filter/basflt/iodetect.cxx
@@ -44,7 +44,8 @@ SwIoDetect aFilterDetect[] =
     SwIoDetect( sWW5 ),
     SwIoDetect( FILTER_XML ),
     SwIoDetect( FILTER_TEXT_DLG ),
-    SwIoDetect( FILTER_TEXT )
+    SwIoDetect( FILTER_TEXT ),
+    SwIoDetect( FILTER_DOCX )
 };
 
 const OUString SwIoSystem::GetSubStorageName( const SfxFilter& rFltr )
diff --git a/sw/source/filter/docx/swdocxreader.cxx b/sw/source/filter/docx/swdocxreader.cxx
new file mode 100644
index 000000000000..5975f1b862bd
--- /dev/null
+++ b/sw/source/filter/docx/swdocxreader.cxx
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "swdocxreader.hxx"
+
+#include <swerror.h>
+
+extern "C" SAL_DLLPUBLIC_EXPORT Reader* SAL_CALL ImportDOCX()
+{
+    return new SwDOCXReader;
+}
+
+sal_uLong SwDOCXReader::Read( SwDoc& /* rDoc */, const OUString& /* rBaseURL */, SwPaM& /* rPaM */, const OUString& /* FileName */ )
+{
+    return ERR_SWG_READ_ERROR;
+}
+
+int SwDOCXReader::GetReaderType()
+{
+    return SW_STORAGE_READER | SW_STREAM_READER;
+}
+
+bool SwDOCXReader::HasGlossaries() const
+{
+    // TODO
+    return true;
+}
+
+bool SwDOCXReader::ReadGlossaries( SwTextBlocks& /* rBlocks */, bool /* bSaveRelFiles */ ) const
+{
+    // TODO
+    return false;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/docx/swdocxreader.hxx b/sw/source/filter/docx/swdocxreader.hxx
new file mode 100644
index 000000000000..35fdee86a643
--- /dev/null
+++ b/sw/source/filter/docx/swdocxreader.hxx
@@ -0,0 +1,40 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_FILTER_DOCX_SWDOCXREADER_HXX
+#define INCLUDED_SW_SOURCE_FILTER_DOCX_SWDOCXREADER_HXX
+
+#include <shellio.hxx>
+
+/// Wrapper for the UNO DOCX import filter (in writerfilter) for autotext purposes.
+class SwDOCXReader : public StgReader
+{
+public:
+    virtual int GetReaderType() override;
+
+    virtual bool HasGlossaries() const override;
+    virtual bool ReadGlossaries( SwTextBlocks& rBlocks, bool bSaveRelFiles ) const override;
+
+private:
+    virtual sal_uLong Read( SwDoc&, const OUString&, SwPaM&, const OUString& ) override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx
index 9d93c26752fb..29d482ac7dea 100644
--- a/sw/source/ui/misc/glossary.cxx
+++ b/sw/source/ui/misc/glossary.cxx
@@ -591,6 +591,12 @@ IMPL_LINK( SwGlossaryDlg, MenuHdl, Menu *, pMn, bool )
                             pFilter->GetWildcard().getGlob() );
                 xFltMgr->setCurrentFilter( pFilter->GetUIName() ) ;
             }
+            else if( pFilter->GetUserData() == FILTER_DOCX )
+            {
+                xFltMgr->appendFilter( pFilter->GetUIName(),
+                            pFilter->GetWildcard().getGlob() );
+                xFltMgr->setCurrentFilter( pFilter->GetUIName() ) ;
+            }
 
             pFilter = aIter.Next();
         }


More information about the Libreoffice-commits mailing list