summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2017-04-14 10:22:37 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2017-04-14 12:24:38 +0200
commit0b31912b1df719c5507b22a2f63086cb8921f597 (patch)
treece039fa56ebe9774c0f7d2b78d82f3886c3f89b1
parent6f20cb94640224c47efa0a9de8ee757260ba3771 (diff)
AutoText: .dotx files visible when import
Change-Id: Idd2cdd9696a15ca5a215fc42b46cc470c4c25a28 Reviewed-on: https://gerrit.libreoffice.org/36550 Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Tested-by: Szymon Kłos <szymon.klos@collabora.com>
-rw-r--r--sw/Library_sw.mk1
-rw-r--r--sw/README1
-rw-r--r--sw/inc/iodetect.hxx2
-rw-r--r--sw/source/filter/basflt/fltini.cxx21
-rw-r--r--sw/source/filter/basflt/iodetect.cxx3
-rw-r--r--sw/source/filter/docx/swdocxreader.cxx51
-rw-r--r--sw/source/filter/docx/swdocxreader.hxx40
-rw-r--r--sw/source/ui/misc/glossary.cxx6
8 files changed, 122 insertions, 3 deletions
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 8e6aea178073..3f24c6d0bff1 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 ea6c88257f55..4305613debac 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: plain 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 e49c8031589f..df3d4aa64a04 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 f0b0c4bd0fb8..8c46c757e454 100644
--- a/sw/source/filter/basflt/fltini.cxx
+++ b/sw/source/filter/basflt/fltini.cxx
@@ -64,9 +64,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
static SwReaderWriterEntry aReaderWriter[] =
{
SwReaderWriterEntry( &::GetRTFReader, &::GetRTFWriter, true ),
@@ -78,7 +79,8 @@ static 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()
@@ -639,6 +641,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& );
}
@@ -703,6 +706,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 11d3a3152c77..0eb82bd8d895 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 8ed1d7c611a4..192b407be077 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();
}