[Libreoffice-commits] .: 6 commits - chart2/source sc/inc sc/source

Muthu Subramanian sumuthu at kemper.freedesktop.org
Sat Oct 16 09:21:14 PDT 2010


 chart2/source/inc/InternalData.hxx           |    2 
 chart2/source/tools/InternalData.cxx         |   38 +++++-
 chart2/source/tools/InternalDataProvider.cxx |   78 ++++++++++++
 sc/inc/unonames.hxx                          |    2 
 sc/source/filter/excel/xeescher.cxx          |  164 ++++++++++++++++++++++++++-
 sc/source/filter/excel/xestream.cxx          |    1 
 sc/source/filter/excel/xlroot.cxx            |   11 +
 sc/source/filter/inc/xcl97rec.hxx            |    5 
 sc/source/filter/inc/xeescher.hxx            |   12 +
 sc/source/filter/inc/xlroot.hxx              |    3 
 sc/source/filter/xcl97/xcl97rec.cxx          |   22 ++-
 sc/source/ui/unoobj/scdetect.cxx             |   77 ++++++------
 sc/source/ui/unoobj/shapeuno.cxx             |   17 ++
 13 files changed, 377 insertions(+), 55 deletions(-)

New commits:
commit fa9fb64fc7ea9a3332367019d086bf5551f4930b
Author: Muthu Subramanian K <sumuthu at novell.com>
Date:   Sat Oct 16 21:44:01 2010 +0530

    Minor fixes for commentPr export merge.

diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx
index f9148f2..59f989d 100644
--- a/sc/source/filter/excel/xeescher.cxx
+++ b/sc/source/filter/excel/xeescher.cxx
@@ -163,11 +163,11 @@ static void lcl_GetFromTo( const XclExpRoot& rRoot, const Rectangle &aRect, INT3
 {
     bool bTo = false;
     INT32 nCol = 0, nRow = 0;
+    INT32 nColOff = 0, nRowOff= 0;
 
     while(1)
     {
         Rectangle r = rRoot.GetDocPtr()->GetMMRect( nCol,nRow,nCol,nRow,nTab );
-        INT32 nColOff, nRowOff;
         if( !bTo )
         {
             if( r.Left() <= aRect.Left() )
@@ -183,7 +183,7 @@ static void lcl_GetFromTo( const XclExpRoot& rRoot, const Rectangle &aRect, INT3
             if( r.Left() > aRect.Left() && r.Top() > aRect.Top() )
             {
                 aFrom = Rectangle( nCol-1, HMM2XL( nColOff ),
-                                   nRow-1, HMM2XL( nRowOff ) ));
+                                   nRow-1, HMM2XL( nRowOff ) );
                 bTo=true;
             }
         }
commit 381b99b434a5bd2402f7813eacda15094aba3bab
Author: Muthu Subramanian K <sumuthu at novell.com>
Date:   Fri Oct 15 15:40:19 2010 +0530

    Adding support for importing charts using InternalData.
    
    This is similar to sc's chart importer.

diff --git a/chart2/source/inc/InternalData.hxx b/chart2/source/inc/InternalData.hxx
index 314bb2e..00c7960 100644
--- a/chart2/source/inc/InternalData.hxx
+++ b/chart2/source/inc/InternalData.hxx
@@ -41,6 +41,8 @@ public:
     InternalData();
 
     void createDefaultData();
+    bool isDefaultData();
+    void clearDefaultData();
 
     void setData( const ::com::sun::star::uno::Sequence<
         ::com::sun::star::uno::Sequence< double > > & rDataInRows );
diff --git a/chart2/source/tools/InternalData.cxx b/chart2/source/tools/InternalData.cxx
index e57e5fa..cede61b 100644
--- a/chart2/source/tools/InternalData.cxx
+++ b/chart2/source/tools/InternalData.cxx
@@ -89,6 +89,13 @@ InternalData::InternalData()
     , m_aColumnLabels( 0 )
 {}
 
+static const double fDefaultData[] = {
+    9.10, 3.20, 4.54,
+    2.40, 8.80, 9.65,
+    3.10, 1.50, 3.70,
+    4.30, 9.02, 6.20
+};
+
 void InternalData::createDefaultData()
 {
     const sal_Int32 nRowCount = 4;
@@ -101,12 +108,6 @@ void InternalData::createDefaultData()
     const OUString aRowName( ::chart::SchResId::getResString( STR_ROW_LABEL ));
     const OUString aColName( ::chart::SchResId::getResString( STR_COLUMN_LABEL ));
 
-    const double fDefaultData[ nSize ] =
-        { 9.10, 3.20, 4.54,
-          2.40, 8.80, 9.65,
-          3.10, 1.50, 3.70,
-          4.30, 9.02, 6.20 };
-
     m_aData.resize( nSize );
     for( sal_Int32 i=0; i<nSize; ++i )
         m_aData[i] = fDefaultData[i];
@@ -122,6 +123,31 @@ void InternalData::createDefaultData()
                 lcl_NumberedStringGenerator( aColName, C2U("%COLUMNNUMBER") ));
 }
 
+bool InternalData::isDefaultData()
+{
+
+    if( m_nRowCount == 4 && m_nColumnCount == 3 )
+    {
+        for( sal_Int32 i=0; i<(4*3); ++i )
+            if( m_aData[i] != fDefaultData[i] )
+                return false;
+
+        return true;
+    }
+    return false;
+}
+
+void InternalData::clearDefaultData()
+{
+    if( isDefaultData() )
+    {
+        m_nRowCount = m_nColumnCount = 1;
+        m_aData.resize( 1 );
+        m_aRowLabels.clear();
+        m_aColumnLabels.clear();
+    }
+}
+
 void InternalData::setData( const Sequence< Sequence< double > >& rDataInRows )
 {
     m_nRowCount = rDataInRows.getLength();
diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx
index 8a37210..50b6945 100644
--- a/chart2/source/tools/InternalDataProvider.cxx
+++ b/chart2/source/tools/InternalDataProvider.cxx
@@ -488,9 +488,80 @@ void InternalDataProvider::lcl_decreaseMapReferences(
 Reference< chart2::data::XDataSequence > InternalDataProvider::lcl_createDataSequenceAndAddToMap(
     const OUString & rRangeRepresentation )
 {
+    OUString aRangeRepresentation = rRangeRepresentation;
+    if( aRangeRepresentation.indexOf('{') >= 0 )
+    {
+        sal_Int32   i, m, n;
+        ::std::vector< double > aNewData;
+        ::std::vector< OUString > aNewLabels;
+        OUString    aToken;
+        sal_Int32   nCategories     = 0;
+        sal_Int32   nIndex          = 0;
+        bool        bValues         = true;
+        bool        bLabelSet       = false;
+        OUString str = aRangeRepresentation.replace('{',' ').replace('}',' ');
+
+        m_aInternalData.clearDefaultData();
+        n = m_aInternalData.getColumnCount();
+        if( n )
+            n = n - 1;
+
+        do
+        {
+            // TODO: This will be problematic if ';' is used in label names
+            // '"' character also needs to be considered in such cases
+            aToken = str.getToken(0,';',nIndex);
+            if( !aToken.getLength() )
+                break;
+            if( aToken.indexOf('"') < 0 )
+            {
+                aNewData.push_back( aToken.toDouble() );
+            }
+            else
+            {
+                aNewLabels.push_back( aToken.replace('"', ' ').trim() );
+                if( !nCategories &&
+                   ( !m_aInternalData.getComplexColumnLabel(n).size() ||
+                     !m_aInternalData.getComplexColumnLabel(n).front().getLength() ) )
+                {
+                    m_aInternalData.setComplexColumnLabel( n, aNewLabels );
+                    bLabelSet = true;
+                }
+                else
+                {
+                    m_aInternalData.setComplexRowLabel(nCategories, aNewLabels);
+                    if(nCategories==1 && bLabelSet)
+                    {
+                        ::std::vector< OUString > aLabels;
+                        m_aInternalData.setComplexRowLabel( 0, m_aInternalData.getComplexColumnLabel( n ) );
+                        m_aInternalData.setComplexColumnLabel( n, aLabels );
+                    }
+                }
+                aNewLabels.pop_back();
+                nCategories++;
+                bValues = false;
+            }
+        } while( nIndex >= 0 );
+
+        if( bValues )
+        {
+            m_aInternalData.insertColumn( n );
+            m_aInternalData.setColumnValues( n, aNewData );
+            aRangeRepresentation = OUString::valueOf( n );
+        }
+        else if( nCategories > 1 )
+        {
+            aRangeRepresentation = lcl_aCategoriesRangeName;
+        }
+        else
+        {
+            aRangeRepresentation = lcl_aLabelRangePrefix+OUString::valueOf( n );
+        }
+    }
+
     Reference< chart2::data::XDataSequence > xSeq(
-        new UncachedDataSequence( this, rRangeRepresentation ));
-    lcl_addDataSequenceToMap( rRangeRepresentation, xSeq );
+        new UncachedDataSequence( this, aRangeRepresentation ));
+    lcl_addDataSequenceToMap( aRangeRepresentation, xSeq );
     return xSeq;
 }
 
@@ -685,8 +756,7 @@ Reference< chart2::data::XDataSequence > SAL_CALL InternalDataProvider::createDa
     else if( aRangeRepresentation.getLength())
     {
         // data
-        sal_Int32 nIndex = aRangeRepresentation.toInt32();
-        return lcl_createDataSequenceAndAddToMap( OUString::valueOf( nIndex ));
+        return lcl_createDataSequenceAndAddToMap( aRangeRepresentation );
     }
 
     return Reference< chart2::data::XDataSequence >();
commit 537da0d932acabd5342f571d0217c4e5061eb663
Author: Muthu Subramanian K <sumuthu at novell.com>
Date:   Fri Oct 15 15:23:40 2010 +0530

    UNO APIs for size and moveProtect of notes.

diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx
index a396e9c..edc63b9 100644
--- a/sc/inc/unonames.hxx
+++ b/sc/inc/unonames.hxx
@@ -188,6 +188,8 @@
 #define SC_UNONAME_VERTPOS          "VertOrientPosition"
 //     #i66550 HLINK_FOR_SHAPES
 #define SC_UNONAME_HYPERLINK        "Hyperlink"
+#define SC_UNONAME_MOVEPROTECT      "MoveProtect"
+#define SC_UNONAME_SIZEPROTECT      "SizeProtect"
 
 //	other cell properties
 #define SC_UNONAME_CHCOLHDR			"ChartColumnAsLabel"
diff --git a/sc/source/ui/unoobj/shapeuno.cxx b/sc/source/ui/unoobj/shapeuno.cxx
index 7572787..73cc76f 100644
--- a/sc/source/ui/unoobj/shapeuno.cxx
+++ b/sc/source/ui/unoobj/shapeuno.cxx
@@ -71,6 +71,7 @@ const SfxItemPropertyMapEntry* lcl_GetShapeMap()
         {MAP_CHAR_LEN(SC_UNONAME_HORIPOS), 0, &getCppuType((sal_Int32*)0), 0, 0 },
         {MAP_CHAR_LEN(SC_UNONAME_IMAGEMAP),	0, &getCppuType((uno::Reference<container::XIndexContainer>*)0), 0, 0 },
         {MAP_CHAR_LEN(SC_UNONAME_VERTPOS), 0, &getCppuType((sal_Int32*)0), 0, 0 },
+        {MAP_CHAR_LEN(SC_UNONAME_MOVEPROTECT), 0, &getCppuType((sal_Bool*)0), 0, 0 },
         // #i66550 HLINK_FOR_SHAPES
         {MAP_CHAR_LEN(SC_UNONAME_HYPERLINK), 0, &getCppuType((rtl::OUString*)0), 0, 0 },
         {0,0,0,0,0,0}
@@ -653,6 +654,15 @@ void SAL_CALL ScShapeObj::setPropertyValue(
         if ( ( aValue >>= sHlink ) && pInfo )
             pInfo->SetHlink( sHlink );
     }
+    else if ( aNameString.EqualsAscii( SC_UNONAME_MOVEPROTECT ) )
+    {
+        if( SdrObject* pObj = this->GetSdrObject() )
+        {
+            sal_Bool aProt = false;
+            if( aValue >>= aProt )
+                pObj->SetMoveProtect( aProt );
+        }
+    }
     else
     {
         GetShapePropertySet();
@@ -841,6 +851,13 @@ uno::Any SAL_CALL ScShapeObj::getPropertyValue( const rtl::OUString& aPropertyNa
             sHlink = pInfo->GetHlink();
         aAny <<= sHlink;
     }
+    else if ( aNameString.EqualsAscii( SC_UNONAME_MOVEPROTECT ) )
+    {
+        sal_Bool aProt = false;
+        if ( SdrObject* pObj = this->GetSdrObject() )
+            aProt = pObj->IsMoveProtect();
+        aAny <<= aProt;
+    }
     else
     {
         GetShapePropertySet();
commit d12eacce0e17c49b06cea3c9969aeb33cefa2209
Author: Muthu Subramanian K <sumuthu at novell.com>
Date:   Fri Oct 15 15:07:29 2010 +0530

    CommentPr Export feature. Also includes note's shape-size export.

diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx
index baed64c..f9148f2 100644
--- a/sc/source/filter/excel/xeescher.cxx
+++ b/sc/source/filter/excel/xeescher.cxx
@@ -67,6 +67,19 @@
 #include "userdat.hxx"
 #include "drwlayer.hxx"
 #include "svx/unoapi.hxx"
+#include "svx/algitem.hxx"
+#include "scitems.hxx"
+#include <editeng/justifyitem.hxx>
+#include "svx/sdtaitm.hxx"
+#include "attrib.hxx"
+#include "document.hxx"
+#include <svx/svdattr.hxx>
+#include "svx/sdr/properties/properties.hxx"
+#include "detfunc.hxx"
+#include "svx/xflclit.hxx"
+#include "svx/xlnstwit.hxx"
+#include "svx/xlnstit.hxx"
+#include "svx/sxmspitm.hxx"
 
 #include <oox/core/tokens.hxx>
 #include <oox/export/drawingml.hxx>
@@ -93,6 +106,104 @@ using ::com::sun::star::table::CellAddress;
 using ::com::sun::star::table::CellRangeAddress;
 using ::oox::drawingml::DrawingML;
 
+#define  HMM2XL(x)        ((x)/26.5)+0.5
+
+// Static Function Helpers
+static const char *ToHorizAlign( SdrTextHorzAdjust eAdjust )
+{
+    switch( eAdjust )
+    {
+        case SDRTEXTHORZADJUST_CENTER:
+            return "center";
+        case SDRTEXTHORZADJUST_RIGHT:
+            return "right";
+        case SDRTEXTHORZADJUST_BLOCK:
+            return "justify";
+        case SDRTEXTHORZADJUST_LEFT:
+        default:
+            return "left";
+    }
+    return "unknown";
+}
+
+static const char *ToVertAlign( SdrTextVertAdjust eAdjust )
+{
+    switch( eAdjust )
+    {
+        case SDRTEXTVERTADJUST_CENTER:
+            return "center";
+        case SDRTEXTVERTADJUST_BOTTOM:
+            return "bottom";
+        case SDRTEXTVERTADJUST_BLOCK:
+            return "justify";
+        case SDRTEXTVERTADJUST_TOP:
+        default:
+            return "top";
+    }
+    return "unknown";
+}
+
+static void lcl_WriteAnchorVertex( sax_fastparser::FSHelperPtr rComments, Rectangle &aRect )
+{
+    rComments->startElement( FSNS( XML_xdr, XML_col ), FSEND );
+    rComments->writeEscaped( OUString::valueOf( aRect.Left() ) );
+    rComments->endElement( FSNS( XML_xdr, XML_col ) );
+    rComments->startElement( FSNS( XML_xdr, XML_colOff ), FSEND );
+    rComments->writeEscaped( OUString::valueOf( aRect.Top() ) );
+    rComments->endElement( FSNS( XML_xdr, XML_colOff ) );
+    rComments->startElement( FSNS( XML_xdr, XML_row ), FSEND );
+    rComments->writeEscaped( OUString::valueOf( aRect.Right() ) );
+    rComments->endElement( FSNS( XML_xdr, XML_row ) );
+    rComments->startElement( FSNS( XML_xdr, XML_rowOff ), FSEND );
+    rComments->writeEscaped( OUString::valueOf( aRect.Bottom() ) );
+    rComments->endElement( FSNS( XML_xdr, XML_rowOff ) );
+}
+
+static void lcl_GetFromTo( const XclExpRoot& rRoot, const Rectangle &aRect, INT32 nTab, Rectangle &aFrom, Rectangle &aTo )
+{
+    bool bTo = false;
+    INT32 nCol = 0, nRow = 0;
+
+    while(1)
+    {
+        Rectangle r = rRoot.GetDocPtr()->GetMMRect( nCol,nRow,nCol,nRow,nTab );
+        INT32 nColOff, nRowOff;
+        if( !bTo )
+        {
+            if( r.Left() <= aRect.Left() )
+            {
+                nCol++;
+                nColOff = aRect.Left() - r.Left();
+            }
+            if( r.Top() <= aRect.Top() )
+            {
+                nRow++;
+                nRowOff = aRect.Top() - r.Top();
+            }
+            if( r.Left() > aRect.Left() && r.Top() > aRect.Top() )
+            {
+                aFrom = Rectangle( nCol-1, HMM2XL( nColOff ),
+                                   nRow-1, HMM2XL( nRowOff ) ));
+                bTo=true;
+            }
+        }
+        if( bTo )
+        {
+            if( r.Right() < aRect.Right() )
+                nCol++;
+            if( r.Bottom() < aRect.Bottom() )
+                nRow++;
+            if( r.Right() >= aRect.Right() && r.Bottom() >= aRect.Bottom() )
+            {
+                aTo = Rectangle( nCol, HMM2XL( aRect.Right() - r.Left() ),
+                                 nRow, HMM2XL( aRect.Bottom() - r.Top() ));
+                break;
+            }
+        }
+    }
+    return;
+}
+
 // Escher client anchor =======================================================
 
 XclExpDffAnchorBase::XclExpDffAnchorBase( const XclExpRoot& rRoot, sal_uInt16 nFlags ) :
@@ -1021,8 +1132,31 @@ XclExpNote::XclExpNote( const XclExpRoot& rRoot, const ScAddress& rScPos,
             // TODO: additional text
             if( pScNote )
                 if( SdrCaptionObj* pCaption = pScNote->GetOrCreateCaption( maScPos ) )
+                {
+                    lcl_GetFromTo( rRoot, pCaption->GetLogicRect(), maScPos.Tab(), maCommentFrom, maCommentTo );
                     if( const OutlinerParaObject* pOPO = pCaption->GetOutlinerParaObject() )
-                        mnObjId = rRoot.GetObjectManager().AddObj( new XclObjComment( rRoot.GetObjectManager(), pCaption->GetLogicRect(), pOPO->GetTextObject(), pCaption, mbVisible, maScPos ) );
+                        mnObjId = rRoot.GetObjectManager().AddObj( new XclObjComment( rRoot.GetObjectManager(), pCaption->GetLogicRect(), pOPO->GetTextObject(), pCaption, mbVisible, maScPos, maCommentFrom, maCommentTo ) );
+
+                    SfxItemSet aItemSet = pCaption->GetMergedItemSet();
+                    meTVA       = pCaption->GetTextVerticalAdjust();
+                    meTHA       = pCaption->GetTextHorizontalAdjust();
+                    mbAutoScale = pCaption->GetFitToSize()?true:false;
+                    mbLocked    = pCaption->IsMoveProtect() | pCaption->IsResizeProtect();
+
+                    // AutoFill style would change if Postit.cxx object creation values are changed
+                    OUString aCol(((XFillColorItem &)GETITEM(aItemSet, XFillColorItem , XATTR_FILLCOLOR)).GetValue());
+                    mbAutoFill  = !aCol.getLength() && (GETITEMVALUE(aItemSet, XFillStyleItem, XATTR_FILLSTYLE, ULONG) == XFILL_SOLID);
+#if 0
+                    // TODO: Get AutoLine bool
+                    aCol = OUString(((XLineStartItem &)GETITEM(aItemSet, XLineStartItem, XATTR_LINESTART)).GetValue());
+                    mbAutoLine = !aCol.getLength() &&
+                                 (GETITEMVALUE(aItemSet, XLineStartWidthItem, XATTR_LINESTARTWIDTH, ULONG) == 200) &&
+                                 (GETITEMBOOL(aItemSet, XATTR_LINESTARTCENTER) == FALSE);
+#endif
+                    mbAutoLine  = true;
+                    mbRowHidden = (rRoot.GetDoc().RowHidden(maScPos.Row(),maScPos.Tab()));
+                    mbColHidden = (rRoot.GetDoc().ColHidden(maScPos.Col(),maScPos.Tab()));
+                }
 
             SetRecSize( 9 + maAuthor.GetSize() );
         }
@@ -1116,6 +1250,33 @@ void XclExpNote::WriteXml( sal_Int32 nAuthorId, XclExpXmlStream& rStrm )
         mpNoteContents->WriteXml( rStrm );
 #endif
     rComments->endElement( XML_text );
+
+    if( rStrm.getVersion() == oox::core::ISOIEC_29500_2008 )
+    {
+        rComments->startElement( XML_commentPr,
+                XML_autoFill,       XclXmlUtils::ToPsz( mbAutoFill ),
+                XML_autoScale,      XclXmlUtils::ToPsz( mbAutoScale ),
+                // XML_autoLine,       XclXmlUtils::ToPsz( mbAutoLine ),
+                XML_colHidden,      XclXmlUtils::ToPsz( mbColHidden ),
+                // XML_defaultSize,    "true",
+                XML_locked,         XclXmlUtils::ToPsz( mbLocked ),
+                XML_rowHidden,      XclXmlUtils::ToPsz( mbRowHidden ),
+                XML_textHAlign,     ToHorizAlign( meTHA ),
+                XML_textVAlign,     ToVertAlign( meTVA ) ,
+                FSEND );
+        rComments->startElement( XML_anchor,
+                XML_moveWithCells, "false",
+                XML_sizeWithCells, "false",
+                FSEND );
+        rComments->startElement( FSNS( XML_xdr, XML_from ), FSEND );
+        lcl_WriteAnchorVertex( rComments, maCommentFrom );
+        rComments->endElement( FSNS( XML_xdr, XML_from ) );
+        rComments->startElement( FSNS( XML_xdr, XML_to ), FSEND );
+        lcl_WriteAnchorVertex( rComments, maCommentTo );
+        rComments->endElement( FSNS( XML_xdr, XML_to ) );
+        rComments->endElement( XML_anchor );
+        rComments->endElement( XML_commentPr );
+    }
     rComments->endElement( XML_comment );
 }
 
@@ -1215,6 +1376,7 @@ void XclExpComments::SaveXml( XclExpXmlStream& rStrm )
 
     rComments->startElement( XML_comments,
             XML_xmlns, "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
+            FSNS( XML_xmlns, XML_xdr ), "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing",
             FSEND );
     rComments->startElement( XML_authors, FSEND );
 
diff --git a/sc/source/filter/excel/xlroot.cxx b/sc/source/filter/excel/xlroot.cxx
index 8a0f3c2..62657fd 100644
--- a/sc/source/filter/excel/xlroot.cxx
+++ b/sc/source/filter/excel/xlroot.cxx
@@ -241,6 +241,17 @@ sal_Int32 XclRoot::GetHmmFromPixelY( double fPixelY ) const
     return static_cast< sal_Int32 >( fPixelY * mrData.mfScreenPixelY + 0.5 );
 }
 
+double XclRoot::GetPixelXFromHmm( sal_Int32 nX ) const
+{
+    return static_cast< double >( (nX - 0.5) / mrData.mfScreenPixelX );
+}
+
+double XclRoot::GetPixelYFromHmm( sal_Int32 nY ) const
+{
+    return static_cast< double >( (nY - 0.5) / mrData.mfScreenPixelY );
+}
+
+
 String XclRoot::RequestPassword( ::comphelper::IDocPasswordVerifier& rVerifier ) const
 {
     ::std::vector< OUString > aDefaultPasswords;
diff --git a/sc/source/filter/inc/xcl97rec.hxx b/sc/source/filter/inc/xcl97rec.hxx
index 3cbd44a..a77d437 100644
--- a/sc/source/filter/inc/xcl97rec.hxx
+++ b/sc/source/filter/inc/xcl97rec.hxx
@@ -152,9 +152,12 @@ class XclObjComment : public XclObj
     std::auto_ptr< SdrCaptionObj >
                                 mpCaption;
     bool                        mbVisible;
+    Rectangle                   maFrom;
+    Rectangle                   maTo;
+
 public:
                                 XclObjComment( XclExpObjectManager& rObjMgr,
-                                    const Rectangle& rRect, const EditTextObject& rEditObj, SdrCaptionObj* pCaption, bool bVisible, const ScAddress& rAddress );
+                                    const Rectangle& rRect, const EditTextObject& rEditObj, SdrCaptionObj* pCaption, bool bVisible, const ScAddress& rAddress, Rectangle &rFrom, Rectangle &To );
     virtual						~XclObjComment();
 
     /** c'tor process for formatted text objects above .
diff --git a/sc/source/filter/inc/xeescher.hxx b/sc/source/filter/inc/xeescher.hxx
index 25d997a..c2affff 100644
--- a/sc/source/filter/inc/xeescher.hxx
+++ b/sc/source/filter/inc/xeescher.hxx
@@ -32,6 +32,8 @@
 #include <filter/msfilter/escherex.hxx>
 #include "xcl97rec.hxx"
 #include "xlescher.hxx"
+#include "svx/sdtaitm.hxx"
+
 
 namespace com { namespace sun { namespace star {
     namespace script { struct ScriptEventDescriptor; }
@@ -369,6 +371,16 @@ private:
     ScAddress           maScPos;        /// Calc cell address of the note.
     sal_uInt16          mnObjId;        /// Escher object ID (BIFF8).
     bool                mbVisible;      /// true = permanently visible.
+    SdrTextHorzAdjust   meTHA;          /// text horizontal adjust
+    SdrTextVertAdjust   meTVA;          /// text vertical adjust
+    bool                mbAutoScale;    /// Auto scale text
+    bool                mbLocked;       /// Position & Size locked
+    bool                mbAutoFill;     /// Auto Fill Style
+    bool                mbAutoLine;     /// Auto Line Style
+    bool                mbColHidden;    /// Column containing the comment is hidden
+    bool                mbRowHidden;    /// Row containing the comment is hidden
+    Rectangle           maCommentFrom;  /// From and From Offset
+    Rectangle           maCommentTo;    /// To and To Offsets
 };
 
 // ============================================================================
diff --git a/sc/source/filter/inc/xlroot.hxx b/sc/source/filter/inc/xlroot.hxx
index 846a102..8415d53 100644
--- a/sc/source/filter/inc/xlroot.hxx
+++ b/sc/source/filter/inc/xlroot.hxx
@@ -184,6 +184,9 @@ public:
     /** Calculates the height of the passed number of pixels in 1/100 mm. */
     sal_Int32           GetHmmFromPixelY( double fPixelY ) const;
 
+    double              GetPixelXFromHmm( sal_Int32 nX ) const;
+    double              GetPixelYFromHmm( sal_Int32 nY ) const;
+
     /** Returns the medium to import from. */
     inline SfxMedium&   GetMedium() const { return mrData.mrMedium; }
     /** Returns the document URL of the imported/exported file. */
diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx
index 6c459ac..debf7e8 100644
--- a/sc/source/filter/xcl97/xcl97rec.cxx
+++ b/sc/source/filter/xcl97/xcl97rec.cxx
@@ -424,11 +424,13 @@ void XclObj::SaveTextRecs( XclExpStream& rStrm )
 
   // --- class XclObjComment ------------------------------------------
 
-XclObjComment::XclObjComment( XclExpObjectManager& rObjMgr, const Rectangle& rRect, const EditTextObject& rEditObj, SdrCaptionObj* pCaption, bool bVisible, const ScAddress& rAddress ) :
+XclObjComment::XclObjComment( XclExpObjectManager& rObjMgr, const Rectangle& rRect, const EditTextObject& rEditObj, SdrCaptionObj* pCaption, bool bVisible, const ScAddress& rAddress, Rectangle &rFrom, Rectangle &rTo ) :
     XclObj( rObjMgr, EXC_OBJTYPE_NOTE, true )
             , maScPos( rAddress )
             , mpCaption( static_cast< SdrCaptionObj* >( pCaption->Clone() ) )
             , mbVisible( bVisible )
+            , maFrom ( rFrom )
+            , maTo ( rTo )
 {
     ProcessEscherObj( rObjMgr.GetRoot(), rRect, pCaption, bVisible);
     // TXO
@@ -524,8 +526,11 @@ class VmlCommentExporter : public VMLExport
     ScAddress           maScPos;
     SdrCaptionObj*      mpCaption;
     bool                mbVisible;
+    Rectangle           maFrom;
+    Rectangle           maTo;
+
 public:
-                        VmlCommentExporter ( sax_fastparser::FSHelperPtr p, ScAddress aScPos, SdrCaptionObj* pCaption, bool bVisible );
+                        VmlCommentExporter ( sax_fastparser::FSHelperPtr p, ScAddress aScPos, SdrCaptionObj* pCaption, bool bVisible, Rectangle &aFrom, Rectangle &aTo );
 protected:
     virtual void        Commit( EscherPropertyContainer& rProps, const Rectangle& rRect );
     virtual sal_Int32   StartShape();
@@ -533,11 +538,14 @@ protected:
 };
 
 
-VmlCommentExporter::VmlCommentExporter( sax_fastparser::FSHelperPtr p, ScAddress aScPos, SdrCaptionObj* pCaption, bool bVisible )
+VmlCommentExporter::VmlCommentExporter( sax_fastparser::FSHelperPtr p, ScAddress aScPos, SdrCaptionObj* pCaption,
+                                        bool bVisible, Rectangle &aFrom, Rectangle &aTo )
     : VMLExport( p )
     , maScPos( aScPos )
     , mpCaption( pCaption )
     , mbVisible( bVisible )
+    , maFrom ( aFrom )
+    , maTo ( aTo )
 {
 }
 
@@ -560,7 +568,11 @@ sal_Int32 VmlCommentExporter::StartShape()
 
 void VmlCommentExporter::EndShape( sal_Int32 nShapeElement )
 {
+    char pAnchor[100];
     sax_fastparser::FSHelperPtr pVmlDrawing = GetFS();
+    snprintf( pAnchor, 100, "%ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld",
+                  maFrom.Left(), maFrom.Top(), maFrom.Right(), maFrom.Bottom(),
+                  maTo.Left(), maTo.Top(), maTo.Right(), maTo.Bottom() );
 
     pVmlDrawing->startElement( FSNS( XML_x, XML_ClientData ),
             XML_ObjectType, "Note",
@@ -569,7 +581,7 @@ void VmlCommentExporter::EndShape( sal_Int32 nShapeElement )
             FSEND );
     pVmlDrawing->singleElement( FSNS( XML_x, XML_SizeWithCells ),
             FSEND );
-    XclXmlUtils::WriteElement( pVmlDrawing, FSNS( XML_x, XML_Anchor ), "2, 15, 0, 15, 4, 31, 4, 21" );
+    XclXmlUtils::WriteElement( pVmlDrawing, FSNS( XML_x, XML_Anchor ), pAnchor );
     XclXmlUtils::WriteElement( pVmlDrawing, FSNS( XML_x, XML_AutoFill ), "False" );
     XclXmlUtils::WriteElement( pVmlDrawing, FSNS( XML_x, XML_Row ), maScPos.Row() );
     XclXmlUtils::WriteElement( pVmlDrawing, FSNS( XML_x, XML_Column ), sal_Int32( maScPos.Col() ) );
@@ -580,7 +592,7 @@ void VmlCommentExporter::EndShape( sal_Int32 nShapeElement )
 
 void XclObjComment::SaveXml( XclExpXmlStream& rStrm )
 {
-    VmlCommentExporter aCommentExporter( rStrm.GetCurrentStream(), maScPos, mpCaption.get(), mbVisible );
+    VmlCommentExporter aCommentExporter( rStrm.GetCurrentStream(), maScPos, mpCaption.get(), mbVisible, maFrom, maTo );
     aCommentExporter.AddSdrObject( *mpCaption );
 }
 
commit 86358630d4816789f6bf1aad2b8a344807634e93
Author: Muthu Subramanian K <sumuthu at novell.com>
Date:   Fri Oct 15 14:59:34 2010 +0530

    Reset vml counters for a new save.

diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx
index 7791776..9e8de93 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -1101,6 +1101,7 @@ bool XclExpXmlStream::exportDocument() throw()
     // SfxMedium::GetOutStream() anywhere in the xlsx export filter code!
     // Instead, write via XOutputStream instance.
     SotStorageRef rStorage = static_cast<SotStorage*>(NULL);
+    XclExpObjList::ResetCounters();
 
     XclExpRootData aData( EXC_BIFF8, *pShell->GetMedium (), rStorage, *pDoc, RTL_TEXTENCODING_DONTKNOW );
     aData.meOutput = EXC_OUTPUT_XML_2007;
commit aecf50d59d0587cce910e1bfd3cdb4e453cf6fe1
Author: Muthu Subramanian K <sumuthu at novell.com>
Date:   Fri Oct 15 14:38:54 2010 +0530

    Merging sc-xml-with-xls-ext.diff from patches.
    
    These changes allow xml files with .xls extensions
    to be opened in calc.

diff --git a/sc/source/ui/unoobj/scdetect.cxx b/sc/source/ui/unoobj/scdetect.cxx
index ad99893..85fb0c6 100644
--- a/sc/source/ui/unoobj/scdetect.cxx
+++ b/sc/source/ui/unoobj/scdetect.cxx
@@ -116,6 +116,7 @@ static const sal_Char __FAR_DATA pFilterExcel95[]	= "MS Excel 95";
 static const sal_Char __FAR_DATA pFilterEx95Temp[]	= "MS Excel 95 Vorlage/Template";
 static const sal_Char __FAR_DATA pFilterExcel97[]	= "MS Excel 97";
 static const sal_Char __FAR_DATA pFilterEx97Temp[]	= "MS Excel 97 Vorlage/Template";
+static const sal_Char __FAR_DATA pFilter2003XML[]   = "MS Excel 2003 XML";
 static const sal_Char __FAR_DATA pFilterDBase[]		= "dBase";
 static const sal_Char __FAR_DATA pFilterDif[]		= "DIF";
 static const sal_Char __FAR_DATA pFilterSylk[]		= "SYLK";
@@ -439,7 +440,8 @@ static BOOL lcl_IsAnyXMLFilter( const SfxFilter* pFilter )
                 bool bIsXLS = false;
                 SvStream* pStream = aMedium.GetInStream();
                 const SfxFilter* pPreselectedFilter = pFilter;
-                if ( pPreselectedFilter && pPreselectedFilter->GetName().SearchAscii("Excel") != STRING_NOTFOUND )
+                if ( ( pPreselectedFilter && pPreselectedFilter->GetName().SearchAscii("Excel") != STRING_NOTFOUND ) ||
+                    ( !aPreselectedFilterName.Len() && pPreselectedFilter->GetFilterName().EqualsAscii( pFilterAscii ) ) )
                     bIsXLS = true;
                 pFilter = 0;
                 if ( pStream )
@@ -722,52 +724,51 @@ static BOOL lcl_IsAnyXMLFilter( const SfxFilter* pFilter )
                             // without the preselection other filters (Writer) take precedence
                             // DBase can't be detected reliably, so it also needs preselection
                             bool bMaybeText = lcl_MayBeAscii( rStr );
-                            if ( pPreselectedFilter->GetFilterName().EqualsAscii(pFilterAscii) && bMaybeText )
+
+                            // get file header
+                            rStr.Seek( 0 );
+                            const int nTrySize = 80;
+                            ByteString aHeader;
+                            for ( int j = 0; j < nTrySize && !rStr.IsEof(); j++ )
                             {
-                                // Text filter is accepted if preselected
-                                pFilter = pPreselectedFilter;
+                                sal_Char c;
+                                rStr >> c;
+                                aHeader += c;
                             }
-                            else
+                            aHeader += '\0';
+
+                            if ( HTMLParser::IsHTMLFormat( aHeader.GetBuffer() ) )
                             {
-                                // get file header
-                                rStr.Seek( 0 );
-                                const int nTrySize = 80;
-                                ByteString aHeader;
-                                for ( int j = 0; j < nTrySize && !rStr.IsEof(); j++ )
+                                // test for HTML
+                                if ( pPreselectedFilter->GetName().EqualsAscii(pFilterHtml) )
                                 {
-                                    sal_Char c;
-                                    rStr >> c;
-                                    aHeader += c;
+                                    pFilter = pPreselectedFilter;
                                 }
-                                aHeader += '\0';
-
-                                if ( HTMLParser::IsHTMLFormat( aHeader.GetBuffer() ) )
+                                else
                                 {
-                                    // test for HTML
-                                    if ( pPreselectedFilter->GetName().EqualsAscii(pFilterHtml) )
-                                    {
-                                        pFilter = pPreselectedFilter;
-                                    }
-                                    else
-                                    {
-                                        pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterHtmlWeb) );
-                                        if ( bIsXLS )
-                                            bFakeXLS = true;
-                                    }
+                                    pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterHtmlWeb) );
+                                    if ( bIsXLS )
+                                        bFakeXLS = true;
                                 }
-                                else if ( bIsXLS && bMaybeText )
-                                {
+                            }
+                            else if ( aHeader.CompareTo( "{\\rtf", 5 ) == COMPARE_EQUAL )
+                            {
+                                // test for RTF
+                                pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterRtf) );
+                            }
+                            else if ( bIsXLS && bMaybeText )
+                            {
+                                aHeader.EraseLeadingChars();
+                                if( aHeader.CompareTo( "<?xml", 5 ) == COMPARE_EQUAL )
+                                    pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilter2003XML) );
+                                else
                                     pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterAscii) );
-                                    bFakeXLS = true;
-                                }
-                                else if ( aHeader.CompareTo( "{\\rtf", 5 ) == COMPARE_EQUAL )
-                                {
-                                    // test for RTF
-                                    pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterRtf) );
-                                }
-                                else if ( pPreselectedFilter->GetName().EqualsAscii(pFilterDBase) && lcl_MayBeDBase( rStr ) )
-                                    pFilter = pPreselectedFilter;
+                                bFakeXLS = true;
                             }
+                            else if ( pPreselectedFilter->GetName().EqualsAscii(pFilterDBase) && lcl_MayBeDBase( rStr ) )
+                                pFilter = pPreselectedFilter;
+                            else if ( pPreselectedFilter->GetFilterName().EqualsAscii(pFilterAscii) && bMaybeText )
+                                pFilter = pPreselectedFilter;
                         }
                     }
                 }


More information about the Libreoffice-commits mailing list