summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@frugalware.org>2012-01-10 18:53:55 +0100
committerMiklos Vajna <vmiklos@frugalware.org>2012-01-11 01:53:18 +0100
commit92c7b6733e55a6ab62bc231ecf0ffd5c0da7c8d2 (patch)
tree46a09ead0b30e16686e557bd60bf51ff5b843a53
parent7cee57f336e3e24393e9280f41d82d372f9a2699 (diff)
fdo#38057 implement RTF import progressbar
-rwxr-xr-xsvx/inc/svx/dialogs.hrc1
-rw-r--r--svx/source/stbctrls/stbctrls.src5
-rw-r--r--writerfilter/Library_rtftok.mk1
-rw-r--r--writerfilter/inc/rtftok/RTFDocument.hxx4
-rw-r--r--writerfilter/source/filter/RtfFilter.cxx8
-rw-r--r--writerfilter/source/rtftok/rtfdocumentfactory.cxx5
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx8
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx4
-rw-r--r--writerfilter/source/rtftok/rtftokenizer.cxx30
-rw-r--r--writerfilter/source/rtftok/rtftokenizer.hxx3
10 files changed, 58 insertions, 11 deletions
diff --git a/svx/inc/svx/dialogs.hrc b/svx/inc/svx/dialogs.hrc
index a1038f1ef1ce..4ef4ad1b3af6 100755
--- a/svx/inc/svx/dialogs.hrc
+++ b/svx/inc/svx/dialogs.hrc
@@ -1175,5 +1175,6 @@
#define RID_SVXBMP_DOC_MODIFIED_FEEDBACK (SVX_OOO_BUILD_START + 3)
#define RID_SVXSTR_DOC_MODIFIED_YES (SVX_OOO_BUILD_START + 4)
#define RID_SVXSTR_DOC_MODIFIED_NO (SVX_OOO_BUILD_START + 5)
+#define RID_SVXSTR_DOC_LOAD (SVX_OOO_BUILD_START + 6)
#endif
diff --git a/svx/source/stbctrls/stbctrls.src b/svx/source/stbctrls/stbctrls.src
index c2e0999dca15..dea916dba6e7 100644
--- a/svx/source/stbctrls/stbctrls.src
+++ b/svx/source/stbctrls/stbctrls.src
@@ -97,6 +97,11 @@ String RID_SVXSTR_DOC_MODIFIED_NO
Text [ en-US ] = "The document has not been modified since the last save.";
};
+String RID_SVXSTR_DOC_LOAD
+{
+ Text [ en-US ] = "Loading document...";
+};
+
// PopupMenu -------------------------------------------------------------
Menu RID_SVXMNU_ZOOM
{
diff --git a/writerfilter/Library_rtftok.mk b/writerfilter/Library_rtftok.mk
index 9ee5cde08440..3835a5dd8b52 100644
--- a/writerfilter/Library_rtftok.mk
+++ b/writerfilter/Library_rtftok.mk
@@ -56,6 +56,7 @@ $(eval $(call gb_Library_add_linked_libs,rtftok,\
utl \
tl \
resourcemodel \
+ vcl \
$(gb_STDLIBS) \
))
diff --git a/writerfilter/inc/rtftok/RTFDocument.hxx b/writerfilter/inc/rtftok/RTFDocument.hxx
index 72fe6bd2d952..15b94eb65606 100644
--- a/writerfilter/inc/rtftok/RTFDocument.hxx
+++ b/writerfilter/inc/rtftok/RTFDocument.hxx
@@ -33,6 +33,7 @@
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/task/XStatusIndicator.hpp>
namespace writerfilter {
namespace rtftok {
@@ -62,7 +63,8 @@ namespace writerfilter {
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext,
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > const & xInputStream,
::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > const & xDstDoc,
- ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > const & xFrame);
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > const & xFrame,
+ ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > const & xStatusIndicator);
};
} // namespace rtftok
} // namespace writerfilter
diff --git a/writerfilter/source/filter/RtfFilter.cxx b/writerfilter/source/filter/RtfFilter.cxx
index 0d0e929d7979..2f549d0f3a9e 100644
--- a/writerfilter/source/filter/RtfFilter.cxx
+++ b/writerfilter/source/filter/RtfFilter.cxx
@@ -35,6 +35,7 @@
#include <dmapper/DomainMapper.hxx>
#include <rtftok/RTFDocument.hxx>
#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/task/XStatusIndicator.hpp>
using namespace ::rtl;
using namespace ::cppu;
@@ -88,14 +89,19 @@ sal_Bool RtfFilter::filter( const uno::Sequence< beans::PropertyValue >& aDescri
uno::Reference<frame::XFrame> xFrame = aMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_FRAME(),
uno::Reference<frame::XFrame>());
+ uno::Reference<task::XStatusIndicator> xStatusIndicator = aMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_STATUSINDICATOR(),
+ uno::Reference<task::XStatusIndicator>());
+
writerfilter::Stream::Pointer_t pStream(
new writerfilter::dmapper::DomainMapper(m_xContext, xInputStream, m_xDstDoc, writerfilter::dmapper::DOCUMENT_RTF));
writerfilter::rtftok::RTFDocument::Pointer_t const pDocument(
- writerfilter::rtftok::RTFDocumentFactory::createDocument(m_xContext, xInputStream, m_xDstDoc, xFrame));
+ writerfilter::rtftok::RTFDocumentFactory::createDocument(m_xContext, xInputStream, m_xDstDoc, xFrame, xStatusIndicator));
pDocument->resolve(*pStream);
#ifdef DEBUG_IMPORT
dmapperLogger->endDocument();
#endif
+ if (xStatusIndicator.is())
+ xStatusIndicator->end();
return sal_True;
}
catch (const uno::Exception& e)
diff --git a/writerfilter/source/rtftok/rtfdocumentfactory.cxx b/writerfilter/source/rtftok/rtfdocumentfactory.cxx
index a397565c085d..8e8868b8554e 100644
--- a/writerfilter/source/rtftok/rtfdocumentfactory.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentfactory.cxx
@@ -33,9 +33,10 @@ namespace rtftok {
RTFDocument::Pointer_t RTFDocumentFactory::createDocument(uno::Reference< uno::XComponentContext > const & xContext,
uno::Reference< io::XInputStream > const & xInputStream,
uno::Reference< lang::XComponent > const & xDstDoc,
- uno::Reference< frame::XFrame > const & xFrame)
+ uno::Reference< frame::XFrame > const & xFrame,
+ uno::Reference< task::XStatusIndicator > const & xStatusIndicator)
{
- return RTFDocument::Pointer_t(new RTFDocumentImpl(xContext, xInputStream, xDstDoc, xFrame));
+ return RTFDocument::Pointer_t(new RTFDocumentImpl(xContext, xInputStream, xDstDoc, xFrame, xStatusIndicator));
}
} // namespace rtftok
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 143bd234cc4b..b79950858e4d 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -248,11 +248,13 @@ static util::DateTime lcl_getDateTime(std::stack<RTFParserState>& aStates)
RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& xContext,
uno::Reference<io::XInputStream> const& xInputStream,
uno::Reference<lang::XComponent> const& xDstDoc,
- uno::Reference<frame::XFrame> const& xFrame)
+ uno::Reference<frame::XFrame> const& xFrame,
+ uno::Reference<task::XStatusIndicator> const& xStatusIndicator)
: m_xContext(xContext),
m_xInputStream(xInputStream),
m_xDstDoc(xDstDoc),
m_xFrame(xFrame),
+ m_xStatusIndicator(xStatusIndicator),
m_nGroup(0),
m_aDefaultState(),
m_bSkipUnknown(false),
@@ -303,7 +305,7 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
m_pGraphicHelper.reset(new oox::GraphicHelper(m_xContext, xFrame, m_xStorage));
- m_pTokenizer.reset(new RTFTokenizer(*this, m_pInStream.get()));
+ m_pTokenizer.reset(new RTFTokenizer(*this, m_pInStream.get(), m_xStatusIndicator));
m_pSdrImport.reset(new RTFSdrImport(*this, m_xDstDoc));
}
@@ -363,7 +365,7 @@ void RTFDocumentImpl::resolveSubstream(sal_uInt32 nPos, Id nId, OUString& rIgnor
{
sal_uInt32 nCurrent = Strm().Tell();
// Seek to header position, parse, then seek back.
- RTFDocumentImpl::Pointer_t pImpl(new RTFDocumentImpl(m_xContext, m_xInputStream, m_xDstDoc, m_xFrame));
+ RTFDocumentImpl::Pointer_t pImpl(new RTFDocumentImpl(m_xContext, m_xInputStream, m_xDstDoc, m_xFrame, m_xStatusIndicator));
pImpl->setSubstream(true);
pImpl->setIgnoreFirst(rIgnoreFirst);
if (m_aAuthor.getLength())
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 5e6fc683a899..178cdb314322 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -288,7 +288,8 @@ namespace writerfilter {
RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& xContext,
uno::Reference<io::XInputStream> const& xInputStream,
uno::Reference<lang::XComponent> const& xDstDoc,
- uno::Reference<frame::XFrame> const& xFrame);
+ uno::Reference<frame::XFrame> const& xFrame,
+ uno::Reference<task::XStatusIndicator> const& xStatusIndicator);
virtual ~RTFDocumentImpl();
virtual void resolve(Stream & rHandler);
virtual std::string getType() const;
@@ -351,6 +352,7 @@ namespace writerfilter {
uno::Reference<io::XInputStream> const& m_xInputStream;
uno::Reference<lang::XComponent> const& m_xDstDoc;
uno::Reference<frame::XFrame> const& m_xFrame;
+ uno::Reference<task::XStatusIndicator> const& m_xStatusIndicator;
uno::Reference<lang::XMultiServiceFactory> m_xModelFactory;
uno::Reference<document::XDocumentProperties> m_xDocumentProperties;
boost::shared_ptr<SvStream> m_pInStream;
diff --git a/writerfilter/source/rtftok/rtftokenizer.cxx b/writerfilter/source/rtftok/rtftokenizer.cxx
index e881ea10c793..415424b47a12 100644
--- a/writerfilter/source/rtftok/rtftokenizer.cxx
+++ b/writerfilter/source/rtftok/rtftokenizer.cxx
@@ -26,6 +26,9 @@
*/
#include <tools/stream.hxx>
+#include <tools/resmgr.hxx>
+#include <svx/dialogs.hrc>
+#include <vcl/svapp.hxx>
#include <rtftokenizer.hxx>
#include <rtfskipdestination.hxx>
@@ -39,9 +42,10 @@ using rtl::OUStringToOString;
namespace writerfilter {
namespace rtftok {
-RTFTokenizer::RTFTokenizer(RTFDocumentImpl& rImport, SvStream* pInStream)
+RTFTokenizer::RTFTokenizer(RTFDocumentImpl& rImport, SvStream* pInStream, uno::Reference<task::XStatusIndicator> const& xStatusIndicator)
: m_rImport(rImport),
- m_pInStream(pInStream)
+ m_pInStream(pInStream),
+ m_xStatusIndicator(xStatusIndicator)
{
}
@@ -61,10 +65,32 @@ int RTFTokenizer::resolveParse()
int ret;
// for hex chars
int b = 0, count = 2;
+ sal_uInt32 nPercentSize;
+ sal_uInt32 nLastPos;
+
+ if (m_xStatusIndicator.is())
+ {
+ static ResMgr* pResMgr = ResMgr::CreateResMgr("svx", Application::GetSettings().GetUILocale());
+ OUString sDocLoad(ResId::toString(ResId(RID_SVXSTR_DOC_LOAD, *pResMgr)));
+
+ sal_uInt32 nCurrentPos = Strm().Tell();
+ Strm().Seek(STREAM_SEEK_TO_END);
+ sal_uInt32 nEndPos = Strm().Tell();
+ Strm().Seek(nCurrentPos);
+ m_xStatusIndicator->start(sDocLoad, nEndPos);
+ nPercentSize = nEndPos / 100;
+
+ m_xStatusIndicator->setValue(nLastPos = nCurrentPos);
+ }
while ((Strm() >> ch, !Strm().IsEof()))
{
//SAL_INFO("writerfilter", OSL_THIS_FUNC << ": parsing character '" << ch << "'");
+
+ sal_uInt32 nCurrentPos = Strm().Tell();
+ if (m_xStatusIndicator.is() && nCurrentPos > (nLastPos + nPercentSize))
+ m_xStatusIndicator->setValue(nLastPos = nCurrentPos);
+
if (m_rImport.getGroup() < 0)
return ERROR_GROUP_UNDER;
if (!m_rImport.isEmpty() && m_rImport.getState().nInternalState == INTERNAL_BIN)
diff --git a/writerfilter/source/rtftok/rtftokenizer.hxx b/writerfilter/source/rtftok/rtftokenizer.hxx
index 3556f9cb9097..3b8dee03cb6a 100644
--- a/writerfilter/source/rtftok/rtftokenizer.hxx
+++ b/writerfilter/source/rtftok/rtftokenizer.hxx
@@ -38,7 +38,7 @@ namespace writerfilter {
class RTFTokenizer
{
public:
- RTFTokenizer(RTFDocumentImpl& rImport, SvStream* pInStream);
+ RTFTokenizer(RTFDocumentImpl& rImport, SvStream* pInStream, uno::Reference<task::XStatusIndicator> const& xStatusIndicator);
virtual ~RTFTokenizer();
int resolveParse();
@@ -50,6 +50,7 @@ namespace writerfilter {
RTFDocumentImpl& m_rImport;
SvStream* m_pInStream;
+ uno::Reference<task::XStatusIndicator> const& m_xStatusIndicator;
};
} // namespace rtftok
} // namespace writerfilter