summaryrefslogtreecommitdiff
path: root/writerfilter/source/dmapper/DomainMapper_Impl.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'writerfilter/source/dmapper/DomainMapper_Impl.cxx')
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx107
1 files changed, 59 insertions, 48 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 4d9a9bd83c35..c6d347a37281 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -80,6 +80,7 @@
#if DEBUG
#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/style/TabStop.hpp>
#endif
#include <map>
@@ -401,7 +402,7 @@ DomainMapper_Impl::DomainMapper_Impl(
m_bIsPageBreakDeferred( false ),
m_bIsInShape( false ),
m_bShapeContextAdded( false ),
- m_TableManager( eDocumentType == DOCUMENT_OOXML ),
+ m_pLastSectionContext( ),
m_nCurrentTabStopIndex( 0 ),
m_sCurrentParaStyleId(),
m_bInStyleSheetImport( false ),
@@ -409,8 +410,11 @@ DomainMapper_Impl::DomainMapper_Impl(
m_bLineNumberingSet( false ),
m_bIsInFootnoteProperties( true ),
m_bIsCustomFtnMark( false ),
- m_bIsParaChange( false )
+ m_bIsParaChange( false ),
+ m_bParaChanged( false ),
+ m_bIsLastParaInSection( false )
{
+ appendTableManager( );
GetBodyText();
uno::Reference< text::XTextAppend > xBodyTextAppend = uno::Reference< text::XTextAppend >( m_xBodyText, uno::UNO_QUERY );
m_aTextAppendStack.push(xBodyTextAppend);
@@ -419,13 +423,18 @@ DomainMapper_Impl::DomainMapper_Impl(
uno::Reference< text::XTextAppendAndConvert > xBodyTextAppendAndConvert( m_xBodyText, uno::UNO_QUERY );
TableDataHandler_t::Pointer_t pTableHandler
(new DomainMapperTableHandler(xBodyTextAppendAndConvert, *this));
- m_TableManager.setHandler(pTableHandler);
+ getTableManager( ).setHandler(pTableHandler);
+
+ getTableManager( ).startLevel();
}
/*-- 01.09.2006 10:22:28---------------------------------------------------
-----------------------------------------------------------------------*/
DomainMapper_Impl::~DomainMapper_Impl()
{
+ RemoveLastParagraph( );
+ getTableManager( ).endLevel();
+ popTableManager( );
}
/*-------------------------------------------------------------------------
@@ -479,6 +488,28 @@ void DomainMapper_Impl::SetDocumentSettingsProperty( const ::rtl::OUString& rPro
}
}
}
+
+void DomainMapper_Impl::RemoveLastParagraph( )
+{
+ uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend;
+ try
+ {
+ uno::Reference< text::XTextCursor > xCursor = xTextAppend->createTextCursor();
+ xCursor->gotoEnd(false);
+ xCursor->goLeft( 1, true );
+ xCursor->setString(::rtl::OUString());
+ }
+ catch( const uno::Exception& rEx)
+ {
+ (void)rEx;
+ }
+}
+
+void DomainMapper_Impl::SetIsLastParagraphInSection( bool bIsLast )
+{
+ m_bIsLastParaInSection = bIsLast;
+}
+
/*-------------------------------------------------------------------------
-----------------------------------------------------------------------*/
@@ -529,6 +560,12 @@ void DomainMapper_Impl::PushListProperties(PropertyMapPtr pListProperties)
void DomainMapper_Impl::PopProperties(ContextType eId)
{
OSL_ENSURE(!m_aPropertyStacks[eId].empty(), "section stack already empty");
+
+ if ( eId == CONTEXT_SECTION )
+ {
+ m_pLastSectionContext = m_aPropertyStacks[eId].top( );
+ }
+
m_aPropertyStacks[eId].pop();
m_aContextStack.pop();
if(!m_aContextStack.empty() && !m_aPropertyStacks[m_aContextStack.top()].empty())
@@ -663,7 +700,7 @@ void DomainMapper_Impl::IncorporateTabStop( const DeletableTabStop & rTabStop )
-----------------------------------------------------------------------*/
uno::Sequence< style::TabStop > DomainMapper_Impl::GetCurrentTabStopAndClear()
{
- uno::Sequence< style::TabStop > aRet( m_aCurrentTabStops.size() );
+ uno::Sequence< style::TabStop > aRet( sal_Int32( m_aCurrentTabStops.size() ) );
style::TabStop* pArray = aRet.getArray();
::std::vector<DeletableTabStop>::const_iterator aIt = m_aCurrentTabStops.begin();
::std::vector<DeletableTabStop>::const_iterator aEndIt = m_aCurrentTabStops.end();
@@ -716,11 +753,11 @@ uno::Any DomainMapper_Impl::GetPropertyFromStyleSheet(PropertyIds eId)
/*-------------------------------------------------------------------------
-----------------------------------------------------------------------*/
-ListTablePtr DomainMapper_Impl::GetListTable()
+ListsManager::Pointer DomainMapper_Impl::GetListTable()
{
if(!m_pListTable)
m_pListTable.reset(
- new ListTable( m_rDMapper, m_xTextFactory ));
+ new ListsManager( m_rDMapper, m_xTextFactory ));
return m_pListTable;
}
@@ -855,7 +892,7 @@ void DomainMapper_Impl::finishParagraph( PropertyMapPtr pPropertyMap )
dmapper_logger->attribute("isIgnor", m_TableManager.isIgnore());
#endif
- if(xTextAppend.is() && ! m_TableManager.isIgnore())
+ if(xTextAppend.is() && ! getTableManager( ).isIgnore())
{
try
{
@@ -1059,7 +1096,7 @@ void DomainMapper_Impl::finishParagraph( PropertyMapPtr pPropertyMap )
}
uno::Reference< text::XTextRange > xTextRange =
xTextAppend->finishParagraph( aProperties );
- m_TableManager.handle(xTextRange);
+ getTableManager( ).handle(xTextRange);
// Set the anchor of the objects to the created paragraph
while ( m_aAnchoredStack.size( ) > 0 && !m_bIsInShape )
@@ -1085,6 +1122,15 @@ void DomainMapper_Impl::finishParagraph( PropertyMapPtr pPropertyMap )
xCur->goLeft( 1 , true );
uno::Reference< text::XTextRange > xParaEnd( xCur, uno::UNO_QUERY );
CheckParaRedline( xParaEnd );
+
+ // Remove the last empty section paragraph if needed
+ if ( m_bIsLastParaInSection && !m_bParaChanged )
+ {
+ RemoveLastParagraph( );
+ m_bIsLastParaInSection = false;
+ }
+
+ m_bParaChanged = false;
}
if( !bKeepLastParagraphProperties )
rAppendContext.pLastParagraphProperties = pToBeSavedProperties;
@@ -1131,7 +1177,7 @@ util::DateTime lcl_DateStringToDateTime( const ::rtl::OUString& rDateTime )
void DomainMapper_Impl::appendTextPortion( const ::rtl::OUString& rString, PropertyMapPtr pPropertyMap )
{
uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend;
- if(xTextAppend.is() && ! m_TableManager.isIgnore())
+ if(xTextAppend.is() && ! getTableManager( ).isIgnore())
{
try
{
@@ -1139,8 +1185,9 @@ void DomainMapper_Impl::appendTextPortion( const ::rtl::OUString& rString, Prope
xTextAppend->appendTextPortion
(rString, pPropertyMap->GetPropertyValues());
CheckRedline( xTextRange );
+ m_bParaChanged = true;
- //m_TableManager.handle(xTextRange);
+ //getTableManager( ).handle(xTextRange);
}
catch(const lang::IllegalArgumentException& rEx)
{
@@ -1164,7 +1211,7 @@ void DomainMapper_Impl::appendTextContent(
{
uno::Reference< text::XTextAppendAndConvert > xTextAppendAndConvert( m_aTextAppendStack.top().xTextAppend, uno::UNO_QUERY );
OSL_ENSURE( xTextAppendAndConvert.is(), "trying to append a text content without XTextAppendAndConvert" );
- if(xTextAppendAndConvert.is() && ! m_TableManager.isIgnore())
+ if(xTextAppendAndConvert.is() && ! getTableManager( ).isIgnore())
{
try
{
@@ -1331,18 +1378,7 @@ void DomainMapper_Impl::PopPageHeaderFooter()
{
//header and footer always have an empty paragraph at the end
//this has to be removed
- uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend;
- try
- {
- uno::Reference< text::XTextCursor > xCursor = xTextAppend->createTextCursor();
- xCursor->gotoEnd(false);
- xCursor->goLeft( 1, true );
- xCursor->setString(::rtl::OUString());
- }
- catch( const uno::Exception& rEx)
- {
- (void)rEx;
- }
+ RemoveLastParagraph( );
m_aTextAppendStack.pop();
}
/*-- 24.05.2007 14:22:28---------------------------------------------------
@@ -1396,9 +1432,6 @@ void DomainMapper_Impl::CreateRedline( uno::Reference< text::XTextRange > xRange
{
if ( pRedline.get( ) )
{
-#if DEBUG
- clog << "REDLINE: Writing redline: " << pRedline->m_nId << endl;
-#endif
try
{
::rtl::OUString sType;
@@ -1427,9 +1460,6 @@ void DomainMapper_Impl::CreateRedline( uno::Reference< text::XTextRange > xRange
}
catch( const uno::Exception & rEx )
{
-#if DEBUG
- clog << "REDLINE: error - " << rtl::OUStringToOString( rEx.Message, RTL_TEXTENCODING_UTF8 ).getStr( ) << endl;
-#endif
( void ) rEx;
OSL_ENSURE( false, "Exception in makeRedline" );
}
@@ -1514,9 +1544,6 @@ void DomainMapper_Impl::PopAnnotation()
void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape > xShape )
{
-#if DEBUG
- clog << "PushShapeContext" << endl;
-#endif
m_bIsInShape = true;
try
{
@@ -1553,10 +1580,6 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape
-----------------------------------------------------------------------*/
void DomainMapper_Impl::PopShapeContext()
{
-#if DEBUG
- clog << "PopShapeContext" << endl;
-#endif
-
if ( m_bShapeContextAdded )
{
m_aTextAppendStack.pop();
@@ -3640,16 +3663,10 @@ void DomainMapper_Impl::AddNewRedline( )
pNew->m_nToken = ooxml::OOXML_mod;
if ( !m_bIsParaChange )
{
-#if DEBUG
- clog << "REDLINE: Adding a new redline to stack" << endl;
-#endif
m_aRedlines.push_back( pNew );
}
else
{
-#if DEBUG
- clog << "REDLINE: Setting a new paragraph redline" << endl;
-#endif
m_pParaRedline.swap( pNew );
}
}
@@ -3708,9 +3725,6 @@ void DomainMapper_Impl::RemoveCurrentRedline( )
{
if ( m_aRedlines.size( ) > 0 )
{
-#if DEBUG
- clog << "REDLINE: Removing back redline" << endl;
-#endif
m_aRedlines.pop_back( );
}
}
@@ -3719,9 +3733,6 @@ void DomainMapper_Impl::ResetParaRedline( )
{
if ( m_pParaRedline.get( ) )
{
-#if DEBUG
- clog << "REDLINE: Cleaning the para redline" << endl;
-#endif
RedlineParamsPtr pEmpty;
m_pParaRedline.swap( pEmpty );
}