DomainMapperTableHandler.cxx (c2ec5d32) DomainMapperTableHandler.cxx (14ac695d)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 257 unchanged lines hidden (view full) ---

266 sal_Int32 nLeftBorderDistance;
267 sal_Int32 nRightBorderDistance;
268 sal_Int32 nTopBorderDistance;
269 sal_Int32 nBottomBorderDistance;
270 PropertyMapPtr pTableDefaults;
271 PropertyMapPtr pTableBorders;
272 TableStyleSheetEntry* pTableStyle;
273 TablePropertyValues_t aTableProperties;
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 257 unchanged lines hidden (view full) ---

266 sal_Int32 nLeftBorderDistance;
267 sal_Int32 nRightBorderDistance;
268 sal_Int32 nTopBorderDistance;
269 sal_Int32 nBottomBorderDistance;
270 PropertyMapPtr pTableDefaults;
271 PropertyMapPtr pTableBorders;
272 TableStyleSheetEntry* pTableStyle;
273 TablePropertyValues_t aTableProperties;
274
274
275 TableInfo()
276 : nLeftBorderDistance(DEF_BORDER_DIST)
277 , nRightBorderDistance(DEF_BORDER_DIST)
278 , nTopBorderDistance(0)
279 , nBottomBorderDistance(0)
280 , pTableDefaults(new PropertyMap)
281 , pTableBorders(new PropertyMap)
282 , pTableStyle(NULL)
283 {
284 }
275 TableInfo()
276 : nLeftBorderDistance(DEF_BORDER_DIST)
277 , nRightBorderDistance(DEF_BORDER_DIST)
278 , nTopBorderDistance(0)
279 , nBottomBorderDistance(0)
280 , pTableDefaults(new PropertyMap)
281 , pTableBorders(new PropertyMap)
282 , pTableStyle(NULL)
283 {
284 }
285
285
286};
286};
287
288TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo & rInfo)
287
288TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(
289 TableInfo & rInfo,
290 const bool bAdjustLeftMarginByDefaultValue )
289{
290 // will receive the table style if any
291 TableStyleSheetEntry* pTableStyle = NULL;
292
293 if( m_aTableProperties.get() )
294 {
295 //create properties from the table attributes
296 //...pPropMap->Insert( PROP_LEFT_MARGIN, false, uno::makeAny( m_nLeftMargin - m_nGapHalf ));

--- 8 unchanged lines hidden (view full) ---

305 {
306 // Apply table style properties recursively
307 ::rtl::OUString sTableStyleName;
308 aTableStyleIter->second >>= sTableStyleName;
309 StyleSheetTablePtr pStyleSheetTable = m_rDMapper_Impl.GetStyleSheetTable();
310 const StyleSheetEntryPtr pStyleSheet = pStyleSheetTable->FindStyleSheetByISTD( sTableStyleName );
311 pTableStyle = dynamic_cast<TableStyleSheetEntry*>( pStyleSheet.get( ) );
312 m_aTableProperties->erase( aTableStyleIter );
291{
292 // will receive the table style if any
293 TableStyleSheetEntry* pTableStyle = NULL;
294
295 if( m_aTableProperties.get() )
296 {
297 //create properties from the table attributes
298 //...pPropMap->Insert( PROP_LEFT_MARGIN, false, uno::makeAny( m_nLeftMargin - m_nGapHalf ));

--- 8 unchanged lines hidden (view full) ---

307 {
308 // Apply table style properties recursively
309 ::rtl::OUString sTableStyleName;
310 aTableStyleIter->second >>= sTableStyleName;
311 StyleSheetTablePtr pStyleSheetTable = m_rDMapper_Impl.GetStyleSheetTable();
312 const StyleSheetEntryPtr pStyleSheet = pStyleSheetTable->FindStyleSheetByISTD( sTableStyleName );
313 pTableStyle = dynamic_cast<TableStyleSheetEntry*>( pStyleSheet.get( ) );
314 m_aTableProperties->erase( aTableStyleIter );
313
315
314 if( pStyleSheet )
315 {
316 // First get the style properties, then the table ones
317 PropertyMapPtr pTableProps( m_aTableProperties );
318 TablePropertyMapPtr pEmptyProps( new TablePropertyMap );
316 if( pStyleSheet )
317 {
318 // First get the style properties, then the table ones
319 PropertyMapPtr pTableProps( m_aTableProperties );
320 TablePropertyMapPtr pEmptyProps( new TablePropertyMap );
319
321
320 m_aTableProperties = pEmptyProps;
322 m_aTableProperties = pEmptyProps;
321
323
322 PropertyMapPtr pMergedProperties = lcl_SearchParentStyleSheetAndMergeProperties(pStyleSheet, pStyleSheetTable);
324 PropertyMapPtr pMergedProperties = lcl_SearchParentStyleSheetAndMergeProperties(pStyleSheet, pStyleSheetTable);
323
325
324#ifdef DEBUG_DMAPPER_TABLE_HANDLER
325 dmapper_logger->startElement("mergedProps");
326 dmapper_logger->addTag(pMergedProperties->toTag());
327 dmapper_logger->endElement("mergedProps");
328#endif
329
330 m_aTableProperties->insert( pMergedProperties );
331 m_aTableProperties->insert( pTableProps );
332
333#ifdef DEBUG_DMAPPER_TABLE_HANDLER
334 dmapper_logger->startElement("TableProperties");
335 dmapper_logger->addTag(m_aTableProperties->toTag());
336 dmapper_logger->endElement("TableProperties");
337#endif
326#ifdef DEBUG_DMAPPER_TABLE_HANDLER
327 dmapper_logger->startElement("mergedProps");
328 dmapper_logger->addTag(pMergedProperties->toTag());
329 dmapper_logger->endElement("mergedProps");
330#endif
331
332 m_aTableProperties->insert( pMergedProperties );
333 m_aTableProperties->insert( pTableProps );
334
335#ifdef DEBUG_DMAPPER_TABLE_HANDLER
336 dmapper_logger->startElement("TableProperties");
337 dmapper_logger->addTag(m_aTableProperties->toTag());
338 dmapper_logger->endElement("TableProperties");
339#endif
338 }
340 }
339 }
341 }
340
342
341 // Set the table default attributes for the cells
342 rInfo.pTableDefaults->insert( m_aTableProperties );
343 // Set the table default attributes for the cells
344 rInfo.pTableDefaults->insert( m_aTableProperties );
343
345
344#ifdef DEBUG_DMAPPER_TABLE_HANDLER
345 dmapper_logger->startElement("TableDefaults");
346 dmapper_logger->addTag(rInfo.pTableDefaults->toTag());
347 dmapper_logger->endElement("TableDefaults");
348#endif
349
350 m_aTableProperties->getValue( TablePropertyMap::GAP_HALF, nGapHalf );
351 m_aTableProperties->getValue( TablePropertyMap::LEFT_MARGIN, nLeftMargin );

--- 106 unchanged lines hidden (view full) ---

458 aTableBorder.IsDistanceValid = false;
459
460 m_aTableProperties->Insert( PROP_TABLE_BORDER, false, uno::makeAny( aTableBorder ) );
461
462#ifdef DEBUG_DMAPPER_TABLE_HANDLER
463 lcl_debug_TableBorder(aTableBorder);
464#endif
465
346#ifdef DEBUG_DMAPPER_TABLE_HANDLER
347 dmapper_logger->startElement("TableDefaults");
348 dmapper_logger->addTag(rInfo.pTableDefaults->toTag());
349 dmapper_logger->endElement("TableDefaults");
350#endif
351
352 m_aTableProperties->getValue( TablePropertyMap::GAP_HALF, nGapHalf );
353 m_aTableProperties->getValue( TablePropertyMap::LEFT_MARGIN, nLeftMargin );

--- 106 unchanged lines hidden (view full) ---

460 aTableBorder.IsDistanceValid = false;
461
462 m_aTableProperties->Insert( PROP_TABLE_BORDER, false, uno::makeAny( aTableBorder ) );
463
464#ifdef DEBUG_DMAPPER_TABLE_HANDLER
465 lcl_debug_TableBorder(aTableBorder);
466#endif
467
466 m_aTableProperties->Insert( PROP_LEFT_MARGIN, false, uno::makeAny( nLeftMargin - nGapHalf - rInfo.nLeftBorderDistance));
467
468 m_aTableProperties->Insert(
469 PROP_LEFT_MARGIN,
470 false,
471 uno::makeAny( nLeftMargin - nGapHalf - ( bAdjustLeftMarginByDefaultValue ? rInfo.nLeftBorderDistance : 0 ) ) );
472
473 // no bottom margin - set it explicitly to avoid inheritance from a set dynamic pool default
474 // which might be provided via document default paragraph properties.
475 m_aTableProperties->Insert( PROP_BOTTOM_MARGIN, false, uno::makeAny( (sal_Int32)0 ) );
476
468 m_aTableProperties->getValue( TablePropertyMap::TABLE_WIDTH, nTableWidth );
469 if( nTableWidth > 0 )
470 m_aTableProperties->Insert( PROP_WIDTH, false, uno::makeAny( nTableWidth ));
477 m_aTableProperties->getValue( TablePropertyMap::TABLE_WIDTH, nTableWidth );
478 if( nTableWidth > 0 )
479 m_aTableProperties->Insert( PROP_WIDTH, false, uno::makeAny( nTableWidth ));
471
480
472 sal_Int32 nHoriOrient = text::HoriOrientation::LEFT_AND_WIDTH;
473 m_aTableProperties->getValue( TablePropertyMap::HORI_ORIENT, nHoriOrient ) ;
474 m_aTableProperties->Insert( PROP_HORI_ORIENT, false, uno::makeAny( sal_Int16(nHoriOrient) ) );
475
476 //fill default value - if not available
477 const PropertyMap::const_iterator aRepeatIter =
478 m_aTableProperties->find( PropertyDefinition( PROP_HEADER_ROW_COUNT, false ) );
479 if( aRepeatIter == m_aTableProperties->end() )
480 m_aTableProperties->Insert( PROP_HEADER_ROW_COUNT, false, uno::makeAny( (sal_Int32)0 ));
481 sal_Int32 nHoriOrient = text::HoriOrientation::LEFT_AND_WIDTH;
482 m_aTableProperties->getValue( TablePropertyMap::HORI_ORIENT, nHoriOrient ) ;
483 m_aTableProperties->Insert( PROP_HORI_ORIENT, false, uno::makeAny( sal_Int16(nHoriOrient) ) );
484
485 //fill default value - if not available
486 const PropertyMap::const_iterator aRepeatIter =
487 m_aTableProperties->find( PropertyDefinition( PROP_HEADER_ROW_COUNT, false ) );
488 if( aRepeatIter == m_aTableProperties->end() )
489 m_aTableProperties->Insert( PROP_HEADER_ROW_COUNT, false, uno::makeAny( (sal_Int32)0 ));
481
490
482 // Remove the PROP_HEADER_ROW_COUNT from the table default to avoid
483 // propagating it to the cells
484 PropertyMap::iterator aDefaultRepeatIt =
485 rInfo.pTableDefaults->find( PropertyDefinition( PROP_HEADER_ROW_COUNT, false ) );
486 if ( aDefaultRepeatIt != rInfo.pTableDefaults->end( ) )
487 rInfo.pTableDefaults->erase( aDefaultRepeatIt );
491 // Remove the PROP_HEADER_ROW_COUNT from the table default to avoid
492 // propagating it to the cells
493 PropertyMap::iterator aDefaultRepeatIt =
494 rInfo.pTableDefaults->find( PropertyDefinition( PROP_HEADER_ROW_COUNT, false ) );
495 if ( aDefaultRepeatIt != rInfo.pTableDefaults->end( ) )
496 rInfo.pTableDefaults->erase( aDefaultRepeatIt );
488
497
489 rInfo.aTableProperties = m_aTableProperties->GetPropertyValues();
498 rInfo.aTableProperties = m_aTableProperties->GetPropertyValues();
490
499
491#ifdef DEBUG_DMAPPER_TABLE_HANDLER
492 dmapper_logger->startElement("debug.tableprops");
493 dmapper_logger->addTag(m_aTableProperties->toTag());
494 dmapper_logger->endElement("debug.tableprops");
495#endif
500#ifdef DEBUG_DMAPPER_TABLE_HANDLER
501 dmapper_logger->startElement("debug.tableprops");
502 dmapper_logger->addTag(m_aTableProperties->toTag());
503 dmapper_logger->endElement("debug.tableprops");
504#endif
496
505
497 }
498
499 return pTableStyle;
500}
501
502CellPropertyValuesSeq_t DomainMapperTableHandler::endTableGetCellProperties(TableInfo & rInfo)
503{
504#ifdef DEBUG_DMAPPER_TABLE_HANDLER

--- 192 unchanged lines hidden (view full) ---

697
698#ifdef DEBUG_DMAPPER_TABLE_HANDLER
699 dmapper_logger->endElement("getRowProperties");
700#endif
701
702 return aRowProperties;
703}
704
506 }
507
508 return pTableStyle;
509}
510
511CellPropertyValuesSeq_t DomainMapperTableHandler::endTableGetCellProperties(TableInfo & rInfo)
512{
513#ifdef DEBUG_DMAPPER_TABLE_HANDLER

--- 192 unchanged lines hidden (view full) ---

706
707#ifdef DEBUG_DMAPPER_TABLE_HANDLER
708 dmapper_logger->endElement("getRowProperties");
709#endif
710
711 return aRowProperties;
712}
713
705void DomainMapperTableHandler::endTable()
714void DomainMapperTableHandler::endTable(
715 const unsigned int nDepth )
706{
707#ifdef DEBUG_DMAPPER_TABLE_HANDLER
708 dmapper_logger->startElement("tablehandler.endTable");
709#endif
710
711 TableInfo aTableInfo;
716{
717#ifdef DEBUG_DMAPPER_TABLE_HANDLER
718 dmapper_logger->startElement("tablehandler.endTable");
719#endif
720
721 TableInfo aTableInfo;
712 aTableInfo.pTableStyle = endTableGetTableStyle(aTableInfo);
722 // adjust left margin only for tables in the body text, not for sub tables.
723 const bool bAdjustLeftMarginByDefaultValue = (nDepth == 0);
724 aTableInfo.pTableStyle =
725 endTableGetTableStyle( aTableInfo, bAdjustLeftMarginByDefaultValue );
713 // expands to uno::Sequence< Sequence< beans::PropertyValues > >
714
715 CellPropertyValuesSeq_t aCellProperties = endTableGetCellProperties(aTableInfo);
716
717 RowPropertyValuesSeq_t aRowProperties = endTableGetRowProperties();
718
719#ifdef DEBUG_DMAPPER_TABLE_HANDLER
720 dmapper_logger->addTag(lcl_PropertyValueSeqToTag(aRowProperties));
721#endif
722
723 if (m_pTableSeq->getLength() > 0)
724 {
725 try
726 {
726 // expands to uno::Sequence< Sequence< beans::PropertyValues > >
727
728 CellPropertyValuesSeq_t aCellProperties = endTableGetCellProperties(aTableInfo);
729
730 RowPropertyValuesSeq_t aRowProperties = endTableGetRowProperties();
731
732#ifdef DEBUG_DMAPPER_TABLE_HANDLER
733 dmapper_logger->addTag(lcl_PropertyValueSeqToTag(aRowProperties));
734#endif
735
736 if (m_pTableSeq->getLength() > 0)
737 {
738 try
739 {
727 uno::Reference<text::XTextTable> xTable = m_xText->convertToTable(*m_pTableSeq,
728 aCellProperties,
729 aRowProperties,
730 aTableInfo.aTableProperties);
740 uno::Reference< text::XTextTable > xTable =
741 m_xText->convertToTable(
742 *m_pTableSeq,
743 aCellProperties,
744 aRowProperties,
745 aTableInfo.aTableProperties );
731
732 m_xTableRange = xTable->getAnchor( );
733 }
734 catch (lang::IllegalArgumentException e)
735 {
736#ifdef DEBUG_DMAPPER_TABLE_HANDLER
737 dmapper_logger->chars("failed to import table!");
738#endif

--- 98 unchanged lines hidden ---
746
747 m_xTableRange = xTable->getAnchor( );
748 }
749 catch (lang::IllegalArgumentException e)
750 {
751#ifdef DEBUG_DMAPPER_TABLE_HANDLER
752 dmapper_logger->chars("failed to import table!");
753#endif

--- 98 unchanged lines hidden ---