[Libreoffice-commits] core.git: Branch 'private/lgodard/calc_notes_import_export' - dictionaries helpcontent2 sc/source xmloff/source

Laurent Godard lgodard.libre at laposte.net
Sat Nov 16 02:07:11 PST 2013


 dictionaries                       |    2 
 helpcontent2                       |    2 
 sc/source/filter/xml/xmlexprt.cxx  |  166 ++++++++-----------------------------
 sc/source/filter/xml/xmlexprt.hxx  |    2 
 xmloff/source/draw/shapeexport.cxx |    5 -
 5 files changed, 46 insertions(+), 131 deletions(-)

New commits:
commit 7d704d28c3a16e1378943c9af962c9b51defc4e0
Author: Laurent Godard <lgodard.libre at laposte.net>
Date:   Fri Nov 15 18:04:29 2013 +0100

    export notes bottlenecks
    
    - annotation autostyles
    - write EditText xml in the annotation reusing existing class
    
    Change-Id: Iddfabde8d76316fdc8ca2f4284dbd5d70aa1f722

diff --git a/dictionaries b/dictionaries
index c6f4f79..a32a341 160000
--- a/dictionaries
+++ b/dictionaries
@@ -1 +1 @@
-Subproject commit c6f4f79b596756f5d45c5264a49232e491b9cd78
+Subproject commit a32a341efdbb9e53a7b832262a41f6fb6454bedf
diff --git a/helpcontent2 b/helpcontent2
index 086ca60..4ae80c4 160000
--- a/helpcontent2
+++ b/helpcontent2
@@ -1 +1 @@
-Subproject commit 086ca602232837bc9c80800487c57e35e242fe7a
+Subproject commit 4ae80c49646df353bada547f4755593bf1a6b209
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 5454438..995f75a 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 cc649bd..87c68d1f 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 e341f71..b5b29b1 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 );
     }
 }
 


More information about the Libreoffice-commits mailing list