diff options
author | sushil_shinde <sushil.shinde@synerzip.com> | 2014-02-28 15:33:10 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-03-07 03:19:07 -0600 |
commit | c6b99eedda03461202f9bf012a422dfd81da72ec (patch) | |
tree | 102e75062d9fc9b78f9378f369fb23c6254f282f /writerfilter | |
parent | af42ac01a4931714d5e362cee253e34b9b3689b1 (diff) |
fdo#75158 : Handled unsupported fields for docx file.
- Handled unsupported fields using fieldmark API.
- Added Unit Test.
Change-Id: I0c69458f330fa2e98821c392ea97410fe1b1e20e
Reviewed-on: https://gerrit.libreoffice.org/8391
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 38 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.hxx | 3 |
2 files changed, 38 insertions, 3 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 0d08a38296f6..7d63908ff666 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -151,6 +151,8 @@ DomainMapper_Impl::DomainMapper_Impl( m_bStartIndex(false), m_bStartBibliography(false), m_bTOCPageRef(false), + m_bStartGenericField(false), + m_bTextInserted(false), m_pLastSectionContext( ), m_pLastCharacterContext(), m_nCurrentTabStopIndex( 0 ), @@ -1146,7 +1148,7 @@ void DomainMapper_Impl::appendTextPortion( const OUString& rString, PropertyMapP } else { - if (m_bStartTOC || m_bStartIndex || m_bStartBibliography) + if (m_bStartTOC || m_bStartIndex || m_bStartBibliography || m_bStartGenericField) { m_bStartedTOC = true; uno::Reference< text::XTextCursor > xTOCTextCursor; @@ -1154,9 +1156,10 @@ void DomainMapper_Impl::appendTextPortion( const OUString& rString, PropertyMapP xTOCTextCursor->gotoEnd(false); if (xTOCTextCursor.is()) { - if (m_bStartIndex || m_bStartBibliography) + if (m_bStartIndex || m_bStartBibliography || m_bStartGenericField) xTOCTextCursor->goLeft(1, false); xTextRange = xTextAppend->insertTextPortion(rString, pValues, xTOCTextCursor); + m_bTextInserted = true; xTOCTextCursor->gotoRange(xTextRange->getEnd(), true); mxTOCTextCursor = xTOCTextCursor; } @@ -3587,6 +3590,28 @@ void DomainMapper_Impl::CloseFieldCommand() break; } } + else + { + /* Unsupported fields will be handled here for docx file. + * To handle unsupported fields used fieldmark API. + */ + static const OUString sAPI_unsupportedfield( "com.sun.star.text.Fieldmark"); + OUString aCode( pContext->GetCommand().trim() ); + xFieldInterface = m_xTextFactory->createInstance(sAPI_unsupportedfield); + const uno::Reference<text::XTextContent> xTextContent(xFieldInterface, uno::UNO_QUERY_THROW); + uno::Reference< text::XTextAppend > xTextAppend; + xTextAppend = m_aTextAppendStack.top().xTextAppend; + uno::Reference< text::XTextCursor > xCrsr = xTextAppend->createTextCursorByRange(pContext->GetStartRange()); + if (xTextContent.is()) + { + xTextAppend->insertTextContent(xCrsr,xTextContent, sal_True); + } + const uno::Reference<uno::XInterface> xContent(xTextContent); + uno::Reference< text::XFormField> xFormField(xContent, uno::UNO_QUERY); + xFormField->setFieldType(aCode); + m_bStartGenericField = true; + pContext->SetFormField( xFormField ); + } //set the text field if there is any pContext->SetTextField( uno::Reference< text::XTextField >( xFieldInterface, uno::UNO_QUERY ) ); } @@ -3819,6 +3844,15 @@ void DomainMapper_Impl::PopFieldContext() xCrsrProperties->setPropertyValue("UnvisitedCharStyleName",uno::makeAny(sDisplayName)); } } + else if(m_bStartGenericField) + { + m_bStartGenericField = false; + if(m_bTextInserted) + { + m_aTextAppendStack.pop(); + m_bTextInserted = false; + } + } } } } diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 6c7cac57cdfc..2b54bb879bc2 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -322,7 +322,8 @@ private: bool m_bStartIndex; bool m_bStartBibliography; bool m_bTOCPageRef; - + bool m_bStartGenericField; + bool m_bTextInserted; LineNumberSettings m_aLineNumberSettings; BookmarkMap_t m_aBookmarkMap; |