summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Godard <lgodard.libre@laposte.net>2013-11-15 18:04:29 +0100
committerLaurent Godard <lgodard.libre@laposte.net>2013-11-16 11:05:07 +0100
commit7d704d28c3a16e1378943c9af962c9b51defc4e0 (patch)
treef49c5c0c7f1f6593fce904fba2b8b2771bed5132
parentea2c91a15d9e8374b2c05cc34af12021f1b1c313 (diff)
- annotation autostyles - write EditText xml in the annotation reusing existing class Change-Id: Iddfabde8d76316fdc8ca2f4284dbd5d70aa1f722
m---------dictionaries0
m---------helpcontent20
-rw-r--r--sc/source/filter/xml/xmlexprt.cxx166
-rw-r--r--sc/source/filter/xml/xmlexprt.hxx2
-rw-r--r--xmloff/source/draw/shapeexport.cxx5
5 files changed, 44 insertions, 129 deletions
diff --git a/dictionaries b/dictionaries
-Subproject c6f4f79b596756f5d45c5264a49232e491b9cd7
+Subproject a32a341efdbb9e53a7b832262a41f6fb6454bed
diff --git a/helpcontent2 b/helpcontent2
-Subproject 086ca602232837bc9c80800487c57e35e242fe7
+Subproject 4ae80c49646df353bada547f4755593bf1a6b20
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 54544381d40b..995f75abdd7a 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -1366,6 +1366,41 @@ void ScXMLExport::ExportCellTextAutoStyles(sal_Int32 nTable)
GetProgressBarHelper()->ChangeReference(GetProgressBarHelper()->GetReference() + nCellCount);
}
+void ScXMLExport::ExportAnnotationsTextAutoStyles()
+{
+ UniReference<XMLPropertySetMapper> xMapper = GetTextParagraphExport()->GetTextPropMapper()->getPropertySetMapper();
+ UniReference<SvXMLAutoStylePoolP> xStylePool = GetAutoStylePool();
+ const ScXMLEditAttributeMap& rAttrMap = GetEditAttributeMap();
+
+ std::vector<sc::NoteEntry> aEntries;
+ pDoc->GetAllNoteEntries(aEntries);
+ std::vector<sc::NoteEntry>::const_iterator it = aEntries.begin(), itEnd = aEntries.end();
+ for (; it != itEnd; ++it)
+ {
+ const ScPostIt& pNote = *it->mpNote;
+ const EditTextObject* pEdit = pNote.GetEditTextObject();
+
+ std::vector<editeng::Section> aAttrs;
+ pEdit->GetAllSections(aAttrs);
+ if (aAttrs.empty())
+ continue;
+
+ std::vector<editeng::Section>::const_iterator itSec = aAttrs.begin(), itSecEnd = aAttrs.end();
+ for (; itSec != itSecEnd; ++itSec)
+ {
+ const std::vector<const SfxPoolItem*>& rSecAttrs = itSec->maAttributes;
+ if (rSecAttrs.empty())
+ // No formats applied to this section. Skip it.
+ continue;
+
+ std::vector<XMLPropertyState> aPropStates;
+ toXMLPropertyStates(aPropStates, rSecAttrs, xMapper, rAttrMap);
+ if (!aPropStates.empty())
+ xStylePool->Add(XML_STYLE_FAMILY_TEXT_TEXT, OUString(), aPropStates, false);
+ }
+ }
+}
+
void ScXMLExport::WriteRowContent()
{
ScMyRowFormatRange aRange;
@@ -2404,126 +2439,8 @@ void ScXMLExport::_ExportAutoStyles()
}
// stored styles for notes
-
- UniReference<SvXMLExportPropertyMapper> xShapeMapper = XMLShapeExport::CreateShapePropMapper( *this );
- GetShapeExport(); // make sure the graphics styles family is added
-
- const std::vector<ScNoteStyleEntry>& rNoteEntries = pSheetData->GetNoteStyles();
- std::vector<ScNoteStyleEntry>::const_iterator aNoteIter = rNoteEntries.begin();
- std::vector<ScNoteStyleEntry>::const_iterator aNoteEnd = rNoteEntries.end();
- while (aNoteIter != aNoteEnd)
- {
- ScAddress aPos = aNoteIter->maCellPos;
- SCTAB nTable = aPos.Tab();
- bool bCopySheet = pDoc->IsStreamValid( nTable );
- if (bCopySheet)
- {
- //! separate method AddStyleFromNote needed?
-
- ScPostIt* pNote = pDoc->GetNote(aPos);
- OSL_ENSURE( pNote, "note not found" );
- if (pNote)
- {
- SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos );
- // all uno shapes are created anyway in CollectSharedData
- Reference<beans::XPropertySet> xShapeProperties( pDrawObj->getUnoShape(), uno::UNO_QUERY );
- if (xShapeProperties.is())
- {
- if ( !aNoteIter->maStyleName.isEmpty() )
- {
- std::vector<XMLPropertyState> xPropStates(xShapeMapper->Filter(xShapeProperties));
- OUString sParent;
- OUString sName( aNoteIter->maStyleName );
- GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_SD_GRAPHICS_ID, sParent, xPropStates);
- GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_SD_GRAPHICS_ID, sName);
- }
- if ( !aNoteIter->maTextStyle.isEmpty() )
- {
- std::vector<XMLPropertyState> xPropStates(
- GetTextParagraphExport()->GetParagraphPropertyMapper()->Filter(xShapeProperties));
- OUString sParent;
- OUString sName( aNoteIter->maTextStyle );
- GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TEXT_PARAGRAPH, sParent, xPropStates);
- GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TEXT_PARAGRAPH, sName);
- }
- }
- }
- }
- ++aNoteIter;
- }
-
- // note paragraph styles
-
- UniReference<SvXMLExportPropertyMapper> xParaPropMapper = GetTextParagraphExport()->GetParagraphPropertyMapper();
-
- const std::vector<ScTextStyleEntry>& rNoteParaEntries = pSheetData->GetNoteParaStyles();
- std::vector<ScTextStyleEntry>::const_iterator aNoteParaIter = rNoteParaEntries.begin();
- std::vector<ScTextStyleEntry>::const_iterator aNoteParaEnd = rNoteParaEntries.end();
- while (aNoteParaIter != aNoteParaEnd)
- {
- ScAddress aPos = aNoteParaIter->maCellPos;
- SCTAB nTable = aPos.Tab();
- bool bCopySheet = pDoc->IsStreamValid( nTable );
- if (bCopySheet)
- {
- ScPostIt* pNote = pDoc->GetNote( aPos );
- OSL_ENSURE( pNote, "note not found" );
- if (pNote)
- {
- SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos );
- Reference<container::XEnumerationAccess> xCellText(pDrawObj->getUnoShape(), uno::UNO_QUERY);
- Reference<beans::XPropertySet> xParaProp(
- lcl_GetEnumerated( xCellText, aNoteParaIter->maSelection.nStartPara ), uno::UNO_QUERY );
- if ( xParaProp.is() )
- {
- std::vector<XMLPropertyState> xPropStates(xParaPropMapper->Filter(xParaProp));
- OUString sParent;
- OUString sName( aNoteParaIter->maName );
- GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TEXT_PARAGRAPH, sParent, xPropStates);
- GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TEXT_PARAGRAPH, sName);
- }
- }
- }
- ++aNoteParaIter;
- }
-
- // note text styles
-
UniReference<SvXMLExportPropertyMapper> xTextPropMapper = XMLTextParagraphExport::CreateCharExtPropMapper( *this );
- const std::vector<ScTextStyleEntry>& rNoteTextEntries = pSheetData->GetNoteTextStyles();
- std::vector<ScTextStyleEntry>::const_iterator aNoteTextIter = rNoteTextEntries.begin();
- std::vector<ScTextStyleEntry>::const_iterator aNoteTextEnd = rNoteTextEntries.end();
- while (aNoteTextIter != aNoteTextEnd)
- {
- ScAddress aPos = aNoteTextIter->maCellPos;
- SCTAB nTable = aPos.Tab();
- bool bCopySheet = pDoc->IsStreamValid( nTable );
- if (bCopySheet)
- {
- ScPostIt* pNote = pDoc->GetNote( aPos );
- OSL_ENSURE( pNote, "note not found" );
- if (pNote)
- {
- SdrCaptionObj* pDrawObj = pNote->GetOrCreateCaption( aPos );
- Reference<text::XSimpleText> xCellText(pDrawObj->getUnoShape(), uno::UNO_QUERY);
- Reference<beans::XPropertySet> xCursorProp(xCellText->createTextCursor(), uno::UNO_QUERY);
- ScDrawTextCursor* pCursor = ScDrawTextCursor::getImplementation( xCursorProp );
- if (pCursor)
- {
- pCursor->SetSelection( aNoteTextIter->maSelection );
-
- std::vector<XMLPropertyState> xPropStates(xTextPropMapper->Filter(xCursorProp));
- OUString sParent;
- OUString sName( aNoteTextIter->maName );
- GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TEXT_TEXT, sParent, xPropStates);
- GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TEXT_TEXT, sName);
- }
- }
- }
- ++aNoteTextIter;
- }
-
// stored text styles
const std::vector<ScTextStyleEntry>& rTextEntries = pSheetData->GetTextStyles();
@@ -2692,6 +2609,8 @@ void ScXMLExport::_ExportAutoStyles()
ExportCellTextAutoStyles(nTable);
}
+ ExportAnnotationsTextAutoStyles();
+
pChangeTrackingExportHelper->CollectAutoStyles();
GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_COLUMN,
@@ -3635,14 +3554,6 @@ void ScXMLExport::exportAnnotationMeta( const uno::Reference < drawing::XShape >
if (pNote)
{
- // TODO : notes
- //is it still usefull, as this call back is only called from ScXMLExport::WriteAnnotation
- // and should be in sync with pCurrentCell
- SdrCaptionObj* pNoteCaption = pNote->GetOrCreateCaption(aCellPos);
- Reference<drawing::XShape> xCurrentShape( pNoteCaption->getUnoShape(), uno::UNO_QUERY );
- if (xCurrentShape.get()!=xShape.get())
- return;
-
OUString sAuthor(pNote->GetAuthor());
if (!sAuthor.isEmpty())
{
@@ -3682,6 +3593,8 @@ void ScXMLExport::exportAnnotationMeta( const uno::Reference < drawing::XShape >
false );
Characters(OUString(aDate));
}
+ // Write the TextEditObject part of the caption
+ WriteEditCell(pNote->GetEditTextObject());
}
}
@@ -3705,7 +3618,6 @@ void ScXMLExport::WriteAnnotation(ScMyCell& rMyCell)
GetShapeExport()->exportShape(xShape, SEF_DEFAULT|SEF_EXPORT_ANNOTATION, NULL);
pCurrentCell = NULL;
-
}
}
diff --git a/sc/source/filter/xml/xmlexprt.hxx b/sc/source/filter/xml/xmlexprt.hxx
index cc649bd3df72..87c68d1f32e7 100644
--- a/sc/source/filter/xml/xmlexprt.hxx
+++ b/sc/source/filter/xml/xmlexprt.hxx
@@ -155,6 +155,7 @@ class ScXMLExport : public SvXMLExport
void ExportColumns(const sal_Int32 nTable, const com::sun::star::table::CellRangeAddress& aColumnHeaderRange, const bool bHasColumnHeader);
void ExportExternalRefCacheStyles();
void ExportCellTextAutoStyles(sal_Int32 nTable);
+ void ExportAnnotationsTextAutoStyles();
void ExportFormatRanges(const sal_Int32 nStartCol, const sal_Int32 nStartRow,
const sal_Int32 nEndCol, const sal_Int32 nEndRow, const sal_Int32 nSheet);
void WriteRowContent();
@@ -279,6 +280,7 @@ public:
virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
virtual void DisposingModel();
+
};
#endif
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index e341f71b82dc..b5b29b1435fe 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -2956,8 +2956,9 @@ void XMLShapeExport::ImpExportCaptionShape(
ImpExportEvents( xShape );
ImpExportGluePoints( xShape );
if( bAnnotation )
- mrExport.exportAnnotationMeta( xShape );
- ImpExportText( xShape );
+ mrExport.exportAnnotationMeta( xShape ); // The text is processed at annotation level
+ else
+ ImpExportText( xShape );
}
}