1 diff --git sw/inc/unoobj.hxx sw/inc/unoobj.hxx
2 index 1b58d7c..9449c03 100644
6 #include <com/sun/star/text/XTextField.hpp>
7 #include <com/sun/star/text/XTextRange.hpp>
8 #include <com/sun/star/text/XText.hpp>
9 +#include <com/sun/star/text/XTextCopy.hpp>
10 #include <com/sun/star/text/XTextContent.hpp>
11 #include <com/sun/star/util/XSortable.hpp>
12 #include <com/sun/star/container/XEnumerationAccess.hpp>
13 @@ -204,7 +205,8 @@ class SwXText : public ::com::sun::star::lang::XTypeProvider,
14 public ::com::sun::star::text::XRelativeTextContentRemove,
15 public ::com::sun::star::beans::XPropertySet,
16 public ::com::sun::star::lang::XUnoTunnel,
17 - public ::com::sun::star::text::XTextAppendAndConvert
18 + public ::com::sun::star::text::XTextAppendAndConvert,
19 + public ::com::sun::star::text::XTextCopy
23 @@ -296,6 +298,8 @@ public:
24 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& TableProperties
25 ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
28 + virtual void SAL_CALL copyText( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCopy >& xSource ) throw (::com::sun::star::uno::RuntimeException);
31 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > createCursor()throw(::com::sun::star::uno::RuntimeException);
32 diff --git sw/source/core/unocore/unotext.cxx sw/source/core/unocore/unotext.cxx
33 index 0373d88..25d95d7 100644
34 --- sw/source/core/unocore/unotext.cxx
35 +++ sw/source/core/unocore/unotext.cxx
41 using namespace ::com::sun::star;
42 using ::rtl::OUString;
44 @@ -148,6 +149,7 @@ uno::Any SAL_CALL SwXText::queryInterface( const uno::Type& rType ) throw(uno::R
45 const uno::Type& rXTextConvert = ::getCppuType((uno::Reference< text::XTextConvert >*)0);
46 const uno::Type& rXTextAppend = ::getCppuType((uno::Reference< text::XTextAppend >*)0);
47 const uno::Type& rXTextAppendAndConvert = ::getCppuType((uno::Reference< text::XTextAppendAndConvert >*)0);
48 + const uno::Type& rXTextCopy = ::getCppuType((uno::Reference< text::XTextCopy >*)0);
51 if(rType == rXTextType)
52 @@ -225,6 +227,11 @@ uno::Any SAL_CALL SwXText::queryInterface( const uno::Type& rType ) throw(uno::R
53 uno::Reference< XTextContentAppend > xRet = this;
54 aRet.setValue(&xRet, rXTextContentAppend );
56 + else if(rType == rXTextCopy )
58 + uno::Reference< XTextCopy > xRet = this;
59 + aRet.setValue(&xRet, rXTextCopy );
63 /* -----------------------------15.03.00 17:42--------------------------------
64 @@ -270,8 +277,8 @@ void SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange,
65 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
68 - if(pRange && pRange->GetDoc() == GetDoc() ||
69 - pCursor && pCursor->GetDoc() == GetDoc())
70 + if( ( pRange && pRange->GetDoc() == GetDoc() ) ||
71 + ( pCursor && pCursor->GetDoc() == GetDoc() ) )
73 const SwStartNode* pOwnStartNode = GetStartNode();
75 @@ -1787,6 +1794,36 @@ bool lcl_SimilarPosition( sal_Int32 nPos1, sal_Int32 nPos2 )
76 return abs( nPos1 - nPos2 ) < COL_POS_FUZZY;
79 +void SwXText::copyText(
80 + const uno::Reference< text::XTextCopy >& xSource )
81 + throw ( uno::RuntimeException )
84 + clog << "TODO - SwXText::copyText()" << endl;
86 + uno::Reference< lang::XUnoTunnel > xTTunnel( xSource, uno::UNO_QUERY_THROW );
88 + pText = reinterpret_cast< SwXText* >(
89 + sal::static_int_cast< sal_IntPtr >( xTTunnel->getSomething( SwXText::getUnoTunnelId()) ));
92 + uno::Reference< text::XText > xText( xSource, uno::UNO_QUERY_THROW );
93 + uno::Reference< text::XTextCursor > xCursor = xText->createTextCursor( );
94 + xCursor->gotoEnd( sal_True );
96 + uno::Reference< lang::XUnoTunnel > xTunnel( xCursor, uno::UNO_QUERY_THROW );
98 + OTextCursorHelper* pCursor = 0;
99 + pCursor = reinterpret_cast< OTextCursorHelper* >(
100 + sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
103 + SwNodeIndex rNdIndex( *GetStartNode( ), 1 );
104 + SwPosition rPos( rNdIndex );
105 + pDoc->CopyRange( *pCursor->GetPaM( ), rPos, false );
109 uno::Reference< text::XTextTable > SwXText::convertToTable(
110 const uno::Sequence< uno::Sequence< uno::Sequence< uno::Reference< text::XTextRange > > > >& rTableRanges,
111 const uno::Sequence< uno::Sequence< uno::Sequence< beans::PropertyValue > > >& rCellProperties,
112 @@ -2153,30 +2190,6 @@ uno::Reference< text::XTextTable > SwXText::convertToTable(
118 - bool bIllegalException = false;
119 - bool bRuntimeException = false;
120 - ::rtl::OUString sMessage;
121 - pDoc->StartUndo(UNDO_START, NULL);
122 - pDoc->EndUndo(UNDO_START, NULL);
123 - if( bIllegalException || bRuntimeException )
125 - SwUndoIter aUndoIter( pFirstPaM.get(), UNDO_EMPTY );
126 - pDoc->Undo(aUndoIter);
127 - if(bIllegalException)
129 - lang::IllegalArgumentException aEx;
130 - aEx.Message = sMessage;
133 - else //if(bRuntimeException)
135 - uno::RuntimeException aEx;
136 - aEx.Message = sMessage;
143 diff --git writerfilter/inc/dmapper/DomainMapper.hxx writerfilter/inc/dmapper/DomainMapper.hxx
144 index e0873f7..3f2ad51 100644
145 --- writerfilter/inc/dmapper/DomainMapper.hxx
146 +++ writerfilter/inc/dmapper/DomainMapper.hxx
147 @@ -66,6 +66,7 @@ using namespace std;
150 class DomainMapper_Impl;
153 // different context types require different sprm handling (e.g. names)
155 @@ -107,6 +108,7 @@ public:
156 virtual void endSectionGroup();
157 virtual void startParagraphGroup();
158 virtual void endParagraphGroup();
159 + virtual void markLastParagraphInSection();
160 virtual void startCharacterGroup();
161 virtual void endCharacterGroup();
162 virtual void startShape( ::com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xShape );
163 @@ -135,6 +137,7 @@ public:
164 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > GetCurrentTextRange();
166 ::rtl::OUString getOrCreateCharStyle( PropertyValueVector_t& rCharProperties );
167 + boost::shared_ptr< ListTable > GetListTable( );
170 void handleUnderlineType(const sal_Int32 nIntValue, const ::boost::shared_ptr<PropertyMap> pContext);
171 diff --git writerfilter/inc/resourcemodel/WW8ResourceModel.hxx writerfilter/inc/resourcemodel/WW8ResourceModel.hxx
172 index 29d176f..7565121 100644
173 --- writerfilter/inc/resourcemodel/WW8ResourceModel.hxx
174 +++ writerfilter/inc/resourcemodel/WW8ResourceModel.hxx
175 @@ -210,6 +210,8 @@ public:
177 virtual void endParagraphGroup() = 0;
179 + virtual void markLastParagraphInSection( ) { };
182 Receives start mark for group with the same character properties.
184 diff --git writerfilter/source/dmapper/DomainMapper.cxx writerfilter/source/dmapper/DomainMapper.cxx
185 index 173da5f..4115846 100644
186 --- writerfilter/source/dmapper/DomainMapper.cxx
187 +++ writerfilter/source/dmapper/DomainMapper.cxx
189 #include <dmapper/DomainMapper.hxx>
190 #include <DomainMapper_Impl.hxx>
191 #include <ConversionHelper.hxx>
192 +#include <ListTable.hxx>
193 #include <ThemeTable.hxx>
194 #include <ModelEventListener.hxx>
195 #include <MeasureHandler.hxx>
196 @@ -4145,7 +4146,10 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp
197 sMessage += ::rtl::OString::valueOf( sal_Int32( nSprmId ), 10 );
198 sMessage += ::rtl::OString(" / 0x");
199 sMessage += ::rtl::OString::valueOf( sal_Int32( nSprmId ), 16 );
200 - OSL_ENSURE( false, sMessage.getStr()); //
201 + sMessage += ::rtl::OString(" / ");
202 + sMessage += ::rtl::OString( rSprm.getName( ).c_str( ) );
203 + clog << sMessage.getStr( ) << endl;
204 +// OSL_ENSURE( false, sMessage.getStr()); //
208 @@ -4222,38 +4226,6 @@ void DomainMapper::startParagraphGroup()
209 -----------------------------------------------------------------------*/
210 void DomainMapper::endParagraphGroup()
212 - //handle unprocessed deferred breaks
213 - PropertyMapPtr pParaProperties = m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH);
214 - if( pParaProperties->hasEmptyPropertyValues() )
216 - PropertyMap::const_iterator aIter = pParaProperties->find(PropertyDefinition( PROP_BREAK_TYPE , false ) );
217 - if( aIter != pParaProperties->end() )
219 - style::BreakType eType;
220 - aIter->second >>= eType;
221 - bool bPage = false;
222 - bool bColumn = false;
223 - if( eType == style::BreakType_PAGE_BEFORE )
225 - else if( eType == style::BreakType_COLUMN_BEFORE )
228 - if( bPage || bColumn )
232 - uno::Reference< beans::XPropertySet > xRangeProperties( m_pImpl->GetTopTextAppend()->getEnd(), uno::UNO_QUERY_THROW );
233 - xRangeProperties->setPropertyValue(
234 - PropertyNameSupplier::GetPropertyNameSupplier().GetName(PROP_BREAK_TYPE),
235 - uno::makeAny( bPage ? style::BreakType_PAGE_BEFORE : style::BreakType_COLUMN_BEFORE));
237 - catch( const uno::Exception& )
244 m_pImpl->PopProperties(CONTEXT_PARAGRAPH);
245 m_pImpl->getTableManager().endParagraphGroup();
246 //frame conversion has to be executed after table conversion
247 @@ -4263,6 +4235,14 @@ void DomainMapper::endParagraphGroup()
251 +void DomainMapper::markLastParagraphInSection( )
253 +#ifdef DEBUG_DOMAINMAPPER
254 + dmapper_logger->element( "markLastParagraphInSection" );
256 + m_pImpl->SetIsLastParagraphInSection( true );
259 void DomainMapper::startShape( uno::Reference< drawing::XShape > xShape )
261 m_pImpl->PushShapeContext( xShape );
262 @@ -4576,6 +4556,7 @@ void DomainMapper::substream(Id rName, ::writerfilter::Reference<Stream>::Pointe
263 dmapper_logger->startElement("substream");
266 + m_pImpl->appendTableManager( );
267 m_pImpl->getTableManager().startLevel();
270 @@ -4645,6 +4626,7 @@ void DomainMapper::substream(Id rName, ::writerfilter::Reference<Stream>::Pointe
273 m_pImpl->getTableManager().endLevel();
274 + m_pImpl->popTableManager( );
276 #ifdef DEBUG_DOMAINMAPPER
277 dmapper_logger->endElement("substream");
278 @@ -4880,5 +4862,10 @@ uno::Reference< text::XTextRange > DomainMapper::GetCurrentTextRange()
279 return pStyleSheets->getOrCreateCharStyle( rCharProperties );
282 +ListTablePtr DomainMapper::GetListTable( )
284 + return m_pImpl->GetListTable( );
287 } //namespace dmapper
288 } //namespace writerfilter
289 diff --git writerfilter/source/dmapper/DomainMapper_Impl.cxx writerfilter/source/dmapper/DomainMapper_Impl.cxx
290 index dfa3c60..f460109 100644
291 --- writerfilter/source/dmapper/DomainMapper_Impl.cxx
292 +++ writerfilter/source/dmapper/DomainMapper_Impl.cxx
293 @@ -403,7 +403,7 @@ DomainMapper_Impl::DomainMapper_Impl(
294 m_bIsPageBreakDeferred( false ),
295 m_bIsInShape( false ),
296 m_bShapeContextAdded( false ),
297 - m_TableManager( eDocumentType == DOCUMENT_OOXML ),
298 + m_pLastSectionContext( ),
299 m_nCurrentTabStopIndex( 0 ),
300 m_sCurrentParaStyleId(),
301 m_bInStyleSheetImport( false ),
302 @@ -411,8 +411,11 @@ DomainMapper_Impl::DomainMapper_Impl(
303 m_bLineNumberingSet( false ),
304 m_bIsInFootnoteProperties( true ),
305 m_bIsCustomFtnMark( false ),
306 - m_bIsParaChange( false )
307 + m_bIsParaChange( false ),
308 + m_bParaChanged( false ),
309 + m_bIsLastParaInSection( false )
311 + appendTableManager( );
313 uno::Reference< text::XTextAppend > xBodyTextAppend = uno::Reference< text::XTextAppend >( m_xBodyText, uno::UNO_QUERY );
314 m_aTextAppendStack.push(xBodyTextAppend);
315 @@ -421,16 +424,18 @@ DomainMapper_Impl::DomainMapper_Impl(
316 uno::Reference< text::XTextAppendAndConvert > xBodyTextAppendAndConvert( m_xBodyText, uno::UNO_QUERY );
317 TableDataHandler_t::Pointer_t pTableHandler
318 (new DomainMapperTableHandler(xBodyTextAppendAndConvert, *this));
319 - m_TableManager.setHandler(pTableHandler);
320 + getTableManager( ).setHandler(pTableHandler);
322 - m_TableManager.startLevel();
323 + getTableManager( ).startLevel();
325 /*-- 01.09.2006 10:22:28---------------------------------------------------
327 -----------------------------------------------------------------------*/
328 DomainMapper_Impl::~DomainMapper_Impl()
330 - m_TableManager.endLevel();
331 + RemoveLastParagraph( );
332 + getTableManager( ).endLevel();
333 + popTableManager( );
335 /*-------------------------------------------------------------------------
337 @@ -484,6 +489,28 @@ void DomainMapper_Impl::SetDocumentSettingsProperty( const ::rtl::OUString& rPro
342 +void DomainMapper_Impl::RemoveLastParagraph( )
344 + uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend;
347 + uno::Reference< text::XTextCursor > xCursor = xTextAppend->createTextCursor();
348 + xCursor->gotoEnd(false);
349 + xCursor->goLeft( 1, true );
350 + xCursor->setString(::rtl::OUString());
352 + catch( const uno::Exception& rEx)
358 +void DomainMapper_Impl::SetIsLastParagraphInSection( bool bIsLast )
360 + m_bIsLastParaInSection = bIsLast;
363 /*-------------------------------------------------------------------------
365 -----------------------------------------------------------------------*/
366 @@ -534,6 +561,15 @@ void DomainMapper_Impl::PushListProperties(PropertyMapPtr pListProperties)
367 void DomainMapper_Impl::PopProperties(ContextType eId)
369 OSL_ENSURE(!m_aPropertyStacks[eId].empty(), "section stack already empty");
371 + if ( eId == CONTEXT_SECTION )
374 + clog << "Saving the last section context" << endl;
376 + m_pLastSectionContext = m_aPropertyStacks[eId].top( );
379 m_aPropertyStacks[eId].pop();
380 m_aContextStack.pop();
381 if(!m_aContextStack.empty() && !m_aPropertyStacks[m_aContextStack.top()].empty())
382 @@ -854,7 +890,7 @@ void DomainMapper_Impl::finishParagraph( PropertyMapPtr pPropertyMap )
383 TextAppendContext& rAppendContext = m_aTextAppendStack.top();
384 uno::Reference< text::XTextAppend > xTextAppend = rAppendContext.xTextAppend;
385 PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
386 - if(xTextAppend.is() && ! m_TableManager.isIgnore())
387 + if(xTextAppend.is() && ! getTableManager( ).isIgnore())
391 @@ -1058,7 +1094,7 @@ void DomainMapper_Impl::finishParagraph( PropertyMapPtr pPropertyMap )
393 uno::Reference< text::XTextRange > xTextRange =
394 xTextAppend->finishParagraph( aProperties );
395 - m_TableManager.handle(xTextRange);
396 + getTableManager( ).handle(xTextRange);
398 // Set the anchor of the objects to the created paragraph
399 while ( m_aAnchoredStack.size( ) > 0 && !m_bIsInShape )
400 @@ -1084,6 +1120,15 @@ void DomainMapper_Impl::finishParagraph( PropertyMapPtr pPropertyMap )
401 xCur->goLeft( 1 , true );
402 uno::Reference< text::XTextRange > xParaEnd( xCur, uno::UNO_QUERY );
403 CheckParaRedline( xParaEnd );
405 + // Remove the last empty section paragraph if needed
406 + if ( m_bIsLastParaInSection && !m_bParaChanged )
408 + RemoveLastParagraph( );
409 + m_bIsLastParaInSection = false;
412 + m_bParaChanged = false;
414 if( !bKeepLastParagraphProperties )
415 rAppendContext.pLastParagraphProperties = pToBeSavedProperties;
416 @@ -1126,7 +1171,7 @@ util::DateTime lcl_DateStringToDateTime( const ::rtl::OUString& rDateTime )
417 void DomainMapper_Impl::appendTextPortion( const ::rtl::OUString& rString, PropertyMapPtr pPropertyMap )
419 uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend;
420 - if(xTextAppend.is() && ! m_TableManager.isIgnore())
421 + if(xTextAppend.is() && ! getTableManager( ).isIgnore())
425 @@ -1134,8 +1179,9 @@ void DomainMapper_Impl::appendTextPortion( const ::rtl::OUString& rString, Prope
426 xTextAppend->appendTextPortion
427 (rString, pPropertyMap->GetPropertyValues());
428 CheckRedline( xTextRange );
429 + m_bParaChanged = true;
431 - //m_TableManager.handle(xTextRange);
432 + //getTableManager( ).handle(xTextRange);
434 catch(const lang::IllegalArgumentException& rEx)
436 @@ -1159,7 +1205,7 @@ void DomainMapper_Impl::appendTextContent(
438 uno::Reference< text::XTextAppendAndConvert > xTextAppendAndConvert( m_aTextAppendStack.top().xTextAppend, uno::UNO_QUERY );
439 OSL_ENSURE( xTextAppendAndConvert.is(), "trying to append a text content without XTextAppendAndConvert" );
440 - if(xTextAppendAndConvert.is() && ! m_TableManager.isIgnore())
441 + if(xTextAppendAndConvert.is() && ! getTableManager( ).isIgnore())
445 @@ -1326,18 +1372,7 @@ void DomainMapper_Impl::PopPageHeaderFooter()
447 //header and footer always have an empty paragraph at the end
448 //this has to be removed
449 - uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend;
452 - uno::Reference< text::XTextCursor > xCursor = xTextAppend->createTextCursor();
453 - xCursor->gotoEnd(false);
454 - xCursor->goLeft( 1, true );
455 - xCursor->setString(::rtl::OUString());
457 - catch( const uno::Exception& rEx)
461 + RemoveLastParagraph( );
462 m_aTextAppendStack.pop();
464 /*-- 24.05.2007 14:22:28---------------------------------------------------
465 diff --git writerfilter/source/dmapper/DomainMapper_Impl.hxx writerfilter/source/dmapper/DomainMapper_Impl.hxx
466 index b120a96..5f33e30 100644
467 --- writerfilter/source/dmapper/DomainMapper_Impl.hxx
468 +++ writerfilter/source/dmapper/DomainMapper_Impl.hxx
469 @@ -298,7 +298,8 @@ private:
470 _PageMar m_aPageMargins;
473 - DomainMapperTableManager m_TableManager;
474 + // TableManagers are stacked: one for each stream to avoid any confusion
475 + std::stack< boost::shared_ptr< DomainMapperTableManager > > m_aTableManagers;
477 //each context needs a stack of currently used attributes
479 @@ -313,6 +314,7 @@ private:
480 SettingsTablePtr m_pSettingsTable;
482 PropertyMapPtr m_pTopContext;
483 + PropertyMapPtr m_pLastSectionContext;
485 ::std::vector<DeletableTabStop> m_aCurrentTabStops;
486 sal_uInt32 m_nCurrentTabStopIndex;
487 @@ -334,6 +336,8 @@ private:
488 RedlineParamsPtr m_pParaRedline;
489 bool m_bIsParaChange;
491 + bool m_bParaChanged;
492 + bool m_bIsLastParaInSection;
495 uno::Reference< beans::XPropertySet > m_xAnnotationField;
496 @@ -356,6 +360,11 @@ public:
498 virtual ~DomainMapper_Impl();
500 + SectionPropertyMap* GetLastSectionContext( )
502 + return dynamic_cast< SectionPropertyMap* >( m_pLastSectionContext.get( ) );
505 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > GetPageStyles();
506 ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > GetBodyText();
507 ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > GetTextFactory() const
508 @@ -381,6 +390,9 @@ public:
509 void StartParaChange( );
510 void EndParaChange( );
512 + void RemoveLastParagraph( );
513 + void SetIsLastParagraphInSection( bool bIsLast );
515 void deferBreak( BreakType deferredBreakType );
516 bool isBreakDeferred( BreakType deferredBreakType );
517 void clearDeferredBreaks();
518 @@ -495,7 +507,24 @@ public:
520 void AddBookmark( const ::rtl::OUString& rBookmarkName, const ::rtl::OUString& rId );
522 - DomainMapperTableManager& getTableManager() { return m_TableManager; }
523 + DomainMapperTableManager& getTableManager()
525 + boost::shared_ptr< DomainMapperTableManager > pMngr = m_aTableManagers.top();
526 + return *pMngr.get( );
529 + void appendTableManager( )
531 + boost::shared_ptr< DomainMapperTableManager > pMngr(
532 + new DomainMapperTableManager( m_eDocumentType == DOCUMENT_OOXML ) );
533 + m_aTableManagers.push( pMngr );
536 + void popTableManager( )
538 + if ( m_aTableManagers.size( ) > 0 )
539 + m_aTableManagers.pop( );
542 void SetLineNumbering( sal_Int32 nLnnMod, sal_Int32 nLnc, sal_Int32 ndxaLnn );
543 bool IsLineNumberingSet() const {return m_bLineNumberingSet;}
544 diff --git writerfilter/source/dmapper/PropertyIds.cxx writerfilter/source/dmapper/PropertyIds.cxx
545 index bc76be7..9e54c06 100644
546 --- writerfilter/source/dmapper/PropertyIds.cxx
547 +++ writerfilter/source/dmapper/PropertyIds.cxx
548 @@ -319,6 +319,7 @@ const rtl::OUString& PropertyNameSupplier::GetName( PropertyIds eId ) const
549 case PROP_INDENT_AT : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IndentAt")); break;
550 case PROP_FIRST_LINE_INDENT : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FirstLineIndent")); break;
551 case PROP_NUMBERING_STYLE_NAME : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NumberingStyleName")); break;
552 + case PROP_OUTLINE_LEVEL : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OutlineLevel")); break;
553 case PROP_LISTTAB_STOP_POSITION : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ListtabStopPosition")); break;
554 case PROP_POSITION_AND_SPACE_MODE : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PositionAndSpaceMode")); break;
555 // case : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("")); break;
556 diff --git writerfilter/source/dmapper/PropertyIds.hxx writerfilter/source/dmapper/PropertyIds.hxx
557 index cdbcf75..b46e502 100644
558 --- writerfilter/source/dmapper/PropertyIds.hxx
559 +++ writerfilter/source/dmapper/PropertyIds.hxx
560 @@ -282,8 +282,9 @@ enum PropertyIds
561 /*243*/ ,PROP_INDENT_AT
562 /*244*/ ,PROP_FIRST_LINE_INDENT
563 /*245*/ ,PROP_NUMBERING_STYLE_NAME
564 -/*246*/ ,PROP_LISTTAB_STOP_POSITION
565 -/*247*/ ,PROP_POSITION_AND_SPACE_MODE
566 +/*246*/ ,PROP_OUTLINE_LEVEL
567 +/*247*/ ,PROP_LISTTAB_STOP_POSITION
568 +/*248*/ ,PROP_POSITION_AND_SPACE_MODE
570 struct PropertyNameSupplier_Impl;
571 class PropertyNameSupplier
572 diff --git writerfilter/source/dmapper/PropertyMap.cxx writerfilter/source/dmapper/PropertyMap.cxx
573 index 861ea92..c5ab256 100644
574 --- writerfilter/source/dmapper/PropertyMap.cxx
575 +++ writerfilter/source/dmapper/PropertyMap.cxx
577 #include <com/sun/star/beans/PropertyValue.hpp>
578 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
579 #include <com/sun/star/table/BorderLine.hpp>
580 +#include <com/sun/star/container/XEnumeration.hpp>
581 +#include <com/sun/star/container/XEnumerationAccess.hpp>
582 #include <com/sun/star/container/XNameContainer.hpp>
583 #include <com/sun/star/style/BreakType.hpp>
584 #include <com/sun/star/text/RelOrientation.hpp>
585 #include <com/sun/star/text/WritingMode.hpp>
586 #include <com/sun/star/text/XTextColumns.hpp>
587 #include <com/sun/star/text/XText.hpp>
588 +#include <com/sun/star/text/XTextCopy.hpp>
590 using namespace ::com::sun::star;
592 @@ -381,14 +384,18 @@ void SectionPropertyMap::ApplyBorderToPageStyles(
593 switch( nValue & 0x07)
595 case 0: /*all styles*/
596 - xFirst = GetPageStyle( xPageStyles, xTextFactory, false );
597 - xSecond = GetPageStyle( xPageStyles, xTextFactory, true );
598 + if ( m_sFollowPageStyleName.getLength( ) > 0 )
599 + xFirst = GetPageStyle( xPageStyles, xTextFactory, false );
600 + if ( m_sFirstPageStyleName.getLength( ) > 0 )
601 + xSecond = GetPageStyle( xPageStyles, xTextFactory, true );
603 case 1: /*first page*/
604 - xFirst = GetPageStyle( xPageStyles, xTextFactory, true );
605 + if ( m_sFirstPageStyleName.getLength( ) > 0 )
606 + xFirst = GetPageStyle( xPageStyles, xTextFactory, true );
608 case 2: /*left and right*/
609 - xFirst = GetPageStyle( xPageStyles, xTextFactory, false );
610 + if ( m_sFollowPageStyleName.getLength( ) > 0 )
611 + xFirst = GetPageStyle( xPageStyles, xTextFactory, false );
613 case 3: //whole document?
614 //todo: how to apply a border to the whole document - find all sections or access all page styles?
615 @@ -565,6 +572,92 @@ bool SectionPropertyMap::HasFooter(bool bFirstPage) const
616 -----------------------------------------------------------------------*/
617 #define MIN_HEAD_FOOT_HEIGHT 100 //minimum header/footer height
619 +void SectionPropertyMap::CopyLastHeaderFooter( bool bFirstPage, DomainMapper_Impl& rDM_Impl )
622 + clog << "START>>> SectionPropertyMap::CopyLastHeaderFooter()" << endl;
624 + SectionPropertyMap* pLastContext = rDM_Impl.GetLastSectionContext( );
625 + if ( pLastContext )
627 + uno::Reference< beans::XPropertySet > xPrevStyle = pLastContext->GetPageStyle(
628 + rDM_Impl.GetPageStyles(),
629 + rDM_Impl.GetTextFactory(),
631 + uno::Reference< beans::XPropertySet > xStyle = GetPageStyle(
632 + rDM_Impl.GetPageStyles(),
633 + rDM_Impl.GetTextFactory(),
636 + PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
639 + // Loop over the Header and Footer properties to copy them
640 + static PropertyIds aProperties[] =
646 + bool bHasPrevHeader = false;
647 + bool bHasHeader = false;
649 + rtl::OUString sHeaderIsOn = rPropNameSupplier.GetName( PROP_HEADER_IS_ON );
650 + xPrevStyle->getPropertyValue( sHeaderIsOn ) >>= bHasPrevHeader;
651 + xStyle->getPropertyValue( sHeaderIsOn ) >>= bHasHeader;
652 + bool bCopyHeader = bHasPrevHeader && !bHasHeader;
655 + xStyle->setPropertyValue( sHeaderIsOn, uno::makeAny( sal_True ) );
657 + bool bHasPrevFooter = false;
658 + bool bHasFooter = false;
660 + rtl::OUString sFooterIsOn = rPropNameSupplier.GetName( PROP_FOOTER_IS_ON );
661 + xPrevStyle->getPropertyValue( sFooterIsOn ) >>= bHasPrevFooter;
662 + xStyle->getPropertyValue( sFooterIsOn ) >>= bHasFooter;
663 + bool bCopyFooter = bHasPrevFooter && !bHasFooter;
666 + xStyle->setPropertyValue( sFooterIsOn, uno::makeAny( sal_True ) );
668 + // Copying the text properties
669 + for ( int i = 0, nNbProps = 2; i < nNbProps; i++ )
671 + bool bIsHeader = ( i < nNbProps / 2 );
672 + PropertyIds aPropId = aProperties[i];
673 + rtl::OUString sName = rPropNameSupplier.GetName( aPropId );
675 + if ( ( bIsHeader && bCopyHeader ) || ( !bIsHeader && bCopyFooter ) )
678 + clog << "Copying ";
679 + clog << rtl::OUStringToOString( sName, RTL_TEXTENCODING_UTF8 ).getStr( ) << endl;
681 + // TODO has to be copied
682 + uno::Reference< text::XTextCopy > xTxt(
683 + xStyle->getPropertyValue( sName ), uno::UNO_QUERY_THROW );
685 + uno::Reference< text::XTextCopy > xPrevTxt(
686 + xPrevStyle->getPropertyValue( sName ), uno::UNO_QUERY_THROW );
688 + xTxt->copyText( xPrevTxt );
692 + catch ( const uno::Exception& e )
695 + clog << "An exception occured in SectionPropertyMap::CopyLastHeaderFooter( ) - ";
696 + clog << rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr( ) << endl;
701 + clog << "END>>> SectionPropertyMap::CopyLastHeaderFooter()" << endl;
705 void SectionPropertyMap::PrepareHeaderFooterProperties( bool bFirstPage )
707 sal_Int32 nTopMargin = m_nTopMargin;
708 @@ -703,6 +796,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
709 /*** if headers/footers are available then the top/bottom margins of the
710 header/footer are copied to the top/bottom margin of the page
712 + CopyLastHeaderFooter( false, rDM_Impl );
713 PrepareHeaderFooterProperties( false );
715 const ::rtl::OUString sTrayIndex = rPropNameSupplier.GetName( PROP_PRINTER_PAPER_TRAY_INDEX );
716 @@ -775,6 +869,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
717 //todo: creating a "First Page" style depends on HasTitlePage und _fFacingPage_
720 + CopyLastHeaderFooter( true, rDM_Impl );
721 PrepareHeaderFooterProperties( true );
722 uno::Reference< beans::XPropertySet > xFirstPageStyle = GetPageStyle(
723 rDM_Impl.GetPageStyles(), rDM_Impl.GetTextFactory(), true );
724 @@ -797,28 +892,24 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
725 //now apply this break at the first paragraph of this section
726 uno::Reference< beans::XPropertySet > xRangeProperties;
727 if( m_bIsFirstSection )
728 - xRangeProperties = uno::Reference< beans::XPropertySet >( rDM_Impl.GetBodyText()->getStart(), uno::UNO_QUERY_THROW );
730 + uno::Reference< container::XEnumerationAccess > xEnumAccess( rDM_Impl.GetBodyText( ), uno::UNO_QUERY_THROW );
731 + uno::Reference< container::XEnumeration > xEnum = xEnumAccess->createEnumeration( );
732 + xRangeProperties = uno::Reference< beans::XPropertySet >( xEnum->nextElement( ), uno::UNO_QUERY_THROW );
735 xRangeProperties = uno::Reference< beans::XPropertySet >( m_xStartingRange, uno::UNO_QUERY_THROW );
737 0 - No break 1 - New Colunn 2 - New page 3 - Even page 4 - odd page */
738 - if( m_nBreakType == 2 || m_nBreakType == 3)
740 - xRangeProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_BREAK_TYPE),
741 - uno::makeAny( m_nBreakType == 2 ? style::BreakType_COLUMN_AFTER : style::BreakType_PAGE_AFTER ) );
745 - xRangeProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_PAGE_DESC_NAME ),
746 - uno::makeAny( m_bTitlePage ? m_sFirstPageStyleName : m_sFollowPageStyleName ));
747 + xRangeProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_PAGE_DESC_NAME ),
748 + uno::makeAny( m_bTitlePage ? m_sFirstPageStyleName : m_sFollowPageStyleName ));
749 // todo: page breaks with odd/even page numbering are not available - find out current page number to check how to change the number
750 // or add even/odd page break types
751 - if(m_bPageNoRestart || m_nPageNumber >= 0)
753 - sal_Int16 nPageNumber = m_nPageNumber >= 0 ? static_cast< sal_Int16 >(m_nPageNumber) : 1;
754 - xRangeProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_PAGE_NUMBER_OFFSET ),
755 - uno::makeAny( nPageNumber ));
757 + if(m_bPageNoRestart || m_nPageNumber >= 0)
759 + sal_Int16 nPageNumber = m_nPageNumber >= 0 ? static_cast< sal_Int16 >(m_nPageNumber) : 1;
760 + xRangeProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_PAGE_NUMBER_OFFSET ),
761 + uno::makeAny( nPageNumber ));
765 diff --git writerfilter/source/dmapper/PropertyMap.hxx writerfilter/source/dmapper/PropertyMap.hxx
766 index 526f902..8f7277e 100644
767 --- writerfilter/source/dmapper/PropertyMap.hxx
768 +++ writerfilter/source/dmapper/PropertyMap.hxx
769 @@ -199,6 +199,7 @@ class SectionPropertyMap : public PropertyMap
770 void _ApplyProperties( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xStyle );
771 ::com::sun::star::uno::Reference< com::sun::star::text::XTextColumns > ApplyColumnProperties(
772 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xFollowPageStyle );
773 + void CopyLastHeaderFooter( bool bFirstPage, DomainMapper_Impl& rDM_Impl );
774 void PrepareHeaderFooterProperties( bool bFirstPage );
775 bool HasHeader( bool bFirstPage ) const;
776 bool HasFooter( bool bFirstPage ) const;
777 @@ -275,6 +276,7 @@ public:
779 void CloseSectionGroup( DomainMapper_Impl& rDM_Impl );
781 +typedef boost::shared_ptr<SectionPropertyMap> SectionPropertyMapPtr;
783 /*-- 28.12.2007 08:17:34---------------------------------------------------
785 diff --git writerfilter/source/dmapper/StyleSheetTable.cxx writerfilter/source/dmapper/StyleSheetTable.cxx
786 index 9bf05a8..f010518 100644
787 --- writerfilter/source/dmapper/StyleSheetTable.cxx
788 +++ writerfilter/source/dmapper/StyleSheetTable.cxx
790 ************************************************************************/
791 #include <StyleSheetTable.hxx>
792 #include <dmapper/DomainMapper.hxx>
793 +#include <ListTable.hxx>
794 #include <ConversionHelper.hxx>
795 #include <TblStylePrHandler.hxx>
796 #include <BorderHandler.hxx>
797 @@ -1157,7 +1158,8 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable )
799 //TODO: Handle cases where a paragraph <> character style relation is needed
800 StyleSheetEntryPtr pParent = FindStyleSheetByISTD( pEntry->sBaseStyleIdentifier );
801 - xStyle->setParentStyle(ConvertStyleName( pParent->sStyleName ));
802 + if ( pParent.get( ) )
803 + xStyle->setParentStyle(ConvertStyleName( pParent->sStyleName ));
805 catch( const uno::RuntimeException& )
807 @@ -1215,12 +1217,43 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable )
809 // Set the outline levels
810 const StyleSheetPropertyMap* pStyleSheetProperties = dynamic_cast<const StyleSheetPropertyMap*>(pEntry ? pEntry->pProperties.get() : 0);
811 + if ( pStyleSheetProperties )
813 + aPropValues.realloc( aPropValues.getLength( ) + 1 );
815 + beans::PropertyValue aLvlVal( rPropNameSupplier.GetName( PROP_OUTLINE_LEVEL ), 0,
816 + uno::makeAny( sal_Int16( pStyleSheetProperties->GetOutlineLevel( ) + 1 ) ),
817 + beans::PropertyState_DIRECT_VALUE );
818 + aPropValues[ aPropValues.getLength( ) - 1 ] = aLvlVal;
820 + if ( pStyleSheetProperties->GetOutlineLevel( ) == 0 )
822 + aPropValues.realloc( aPropValues.getLength( ) + 1 );
823 + beans::PropertyValue aStyleVal( rPropNameSupplier.GetName( PROP_NUMBERING_STYLE_NAME ), 0,
824 + uno::makeAny( rtl::OUString::createFromAscii( "" ) ),
825 + beans::PropertyState_DIRECT_VALUE );
826 + aPropValues[ aPropValues.getLength( ) - 1 ] = aStyleVal;
830 if ( pStyleSheetProperties && pStyleSheetProperties->GetOutlineLevel( ) >= 0 )
832 + ListTablePtr pListTable = m_pImpl->m_rDMapper.GetListTable( );
833 + sal_Int32 nNumId = pStyleSheetProperties->GetListId( );
834 + uno::Reference< container::XIndexReplace> xStyleRules = pListTable->GetNumberingRules( nNumId );
835 sal_Int16 nLvl = pStyleSheetProperties->GetOutlineLevel( );
836 uno::Reference< text::XChapterNumberingSupplier > xOutlines ( m_pImpl->m_xTextDocument,
837 uno::UNO_QUERY_THROW );
839 uno::Reference< container::XIndexReplace > xRules = xOutlines->getChapterNumberingRules( );
840 + if ( xStyleRules.is( ) )
842 + for ( sal_Int32 i = 0, nCount = xStyleRules->getCount( ); i < nCount; i++ )
844 + xRules->replaceByIndex( i, xStyleRules->getByIndex( i ) );
848 uno::Any aLevel = xRules->getByIndex( nLvl );
849 uno::Sequence< beans::PropertyValue > aLevelProps;
850 aLevel >>= aLevelProps;
851 diff --git writerfilter/source/ooxml/OOXMLDocumentImpl.cxx writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
852 index fef00e4..df80785 100644
853 --- writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
854 +++ writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
855 @@ -48,7 +48,7 @@ using namespace ::std;
857 OOXMLDocumentImpl::OOXMLDocumentImpl
858 (OOXMLStream::Pointer_t pStream)
859 -: mpStream(pStream), mXNoteType(0)
860 +: mpStream(pStream), mXNoteType(0), mbIsSubstream( false )
864 @@ -138,6 +138,7 @@ OOXMLDocumentImpl::getSubStream(const rtl::OUString & rId)
865 writerfilter::Reference<Stream>::Pointer_t pRet( pTemp = new OOXMLDocumentImpl(pStream) );
866 pTemp->setModel(mxModel);
867 pTemp->setDrawPage(mxDrawPage);
868 + pTemp->setIsSubstream( true );
872 @@ -317,6 +318,7 @@ void OOXMLDocumentImpl::resolve(Stream & rStream)
873 pDocHandler->setStream(&rStream);
874 pDocHandler->setDocument(this);
875 pDocHandler->setXNoteId(msXNoteId);
876 + pDocHandler->setIsSubstream( mbIsSubstream );
877 uno::Reference < xml::sax::XFastDocumentHandler > xDocumentHandler
879 uno::Reference < xml::sax::XFastTokenHandler > xTokenHandler
880 diff --git writerfilter/source/ooxml/OOXMLDocumentImpl.hxx writerfilter/source/ooxml/OOXMLDocumentImpl.hxx
881 index ca2c919..9649376 100644
882 --- writerfilter/source/ooxml/OOXMLDocumentImpl.hxx
883 +++ writerfilter/source/ooxml/OOXMLDocumentImpl.hxx
884 @@ -53,6 +53,8 @@ class OOXMLDocumentImpl : public OOXMLDocument
885 uno::Reference<frame::XModel> mxModel;
886 uno::Reference<drawing::XDrawPage> mxDrawPage;
888 + bool mbIsSubstream;
891 virtual void resolveFastSubStream(Stream & rStream,
892 OOXMLStream::StreamType_t nType);
893 @@ -69,6 +71,8 @@ protected:
895 const rtl::OUString & rNoteId);
897 + void setIsSubstream( bool bSubstream ) { mbIsSubstream = bSubstream; };
900 OOXMLDocumentImpl(OOXMLStream::Pointer_t pStream);
901 virtual ~OOXMLDocumentImpl();
902 diff --git writerfilter/source/ooxml/OOXMLFastContextHandler.cxx writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
903 index 162ada2..fdaf476 100644
904 --- writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
905 +++ writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
906 @@ -752,6 +752,7 @@ void OOXMLFastContextHandler::setLastParagraphInSection()
909 mpParserState->setLastParagraphInSection(true);
910 + mpStream->markLastParagraphInSection( );
913 void OOXMLFastContextHandler::newProperty
914 diff --git writerfilter/source/ooxml/OOXMLFastDocumentHandler.cxx writerfilter/source/ooxml/OOXMLFastDocumentHandler.cxx
915 index 2557387..016599a 100644
916 --- writerfilter/source/ooxml/OOXMLFastDocumentHandler.cxx
917 +++ writerfilter/source/ooxml/OOXMLFastDocumentHandler.cxx
918 @@ -225,4 +225,9 @@ void OOXMLFastDocumentHandler::setXNoteId(const ::rtl::OUString & rXNoteId)
919 msXNoteId = rXNoteId;
922 +void OOXMLFastDocumentHandler::setIsSubstream( bool bSubstream )
924 + getContextHandler( )->getParserState( )->setInSectionGroup( bSubstream );
928 diff --git writerfilter/source/ooxml/OOXMLFastDocumentHandler.hxx writerfilter/source/ooxml/OOXMLFastDocumentHandler.hxx
929 index c7dfefe..b8ed9a5 100644
930 --- writerfilter/source/ooxml/OOXMLFastDocumentHandler.hxx
931 +++ writerfilter/source/ooxml/OOXMLFastDocumentHandler.hxx
932 @@ -100,6 +100,8 @@ public:
934 OOXMLParserState::Pointer_t getParserState() const;
936 + void setIsSubstream( bool bSubstream );
939 OOXMLFastDocumentHandler(OOXMLFastDocumentHandler &); // not defined
940 void operator =(OOXMLFastDocumentHandler &); // not defined
941 diff --git writerfilter/source/ooxml/model.xml writerfilter/source/ooxml/model.xml
942 index add4a80..7d07b6a 100644
943 --- writerfilter/source/ooxml/model.xml
944 +++ writerfilter/source/ooxml/model.xml
945 @@ -22048,18 +22048,13 @@
946 <resource xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" name="CT_HdrFtrRef" resource="Properties">
947 <attribute name="type" tokenid="ooxml:CT_HdrFtrRef_type"/>
948 <attribute name="r:id" tokenid="ooxml:CT_HdrFtrRef_id"/>
949 - <action name="end" action="endCharacterGroup"/>
950 - <action name="end" action="endParagraphGroup"/>
951 <action name="end" action="handleHdrFtr"/>
953 <resource name="EG_HdrFtrReferences" resource="Properties">
954 <element name="headerReference" tokenid="ooxml:EG_HdrFtrReferences_headerReference"/>
955 <element name="footerReference" tokenid="ooxml:EG_HdrFtrReferences_footerReference"/>
957 - <resource name="CT_HdrFtr" resource="Stream">
958 - <action name="start" action="startSectionGroup"/>
959 - <action name="end" action="endSectionGroup"/>
961 + <resource name="CT_HdrFtr" resource="Stream"/>
962 <resource name="EG_SectPrContents" resource="Properties">
963 <element name="bidi" tokenid="ooxml:EG_SectPrContents_bidi"/>
964 <element name="cols" tokenid="ooxml:EG_SectPrContents_cols"/>
965 diff --git writerfilter/source/resourcemodel/TagLogger.cxx writerfilter/source/resourcemodel/TagLogger.cxx
966 index ff23dfc..97f3f28 100644
967 --- writerfilter/source/resourcemodel/TagLogger.cxx
968 +++ writerfilter/source/resourcemodel/TagLogger.cxx
969 @@ -273,7 +273,7 @@ namespace writerfilter
971 fileName += "/writerfilter.";
973 - fileName += ".tmp";
974 + fileName += ".xml";
976 ofstream dumpStream(fileName.c_str());
977 aIt->second->output(dumpStream);