[Libreoffice-commits] .: Branch 'distro/suse/suse-3.6' - 2 commits - oox/inc oox/source sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Dec 14 04:05:00 PST 2012


 oox/inc/oox/core/relations.hxx            |    2 ++
 oox/source/core/relations.cxx             |    6 ++++++
 oox/source/drawingml/hyperlinkcontext.cxx |    5 +++++
 sc/source/filter/inc/worksheetbuffer.hxx  |    4 ++++
 sc/source/filter/oox/drawingfragment.cxx  |   21 ++++++++++++++++++++-
 sc/source/filter/oox/workbookhelper.cxx   |    7 ++-----
 sc/source/filter/oox/worksheetbuffer.cxx  |   19 +++++++++++++++++++
 7 files changed, 58 insertions(+), 6 deletions(-)

New commits:
commit f851a46abac1460376d9030bf8525c509ed590ce
Author: Noel Power <noel.power at suse.com>
Date:   Thu Dec 13 16:52:50 2012 +0000

    fix sometimes data corruption with xlsx import ( with scenario sheets )
    
    formula import is buffered 'till the end of import. The processing of the
    formula data need to happen before the scenario import happens. This is
    necessary because sheet numbers stored in the formula addresses can become
    invalid as scenario import insertes new hidden sheets upsetting the previous
    table order
    
    Change-Id: I9357f028f31bec1b1504ca991f5534f80d79c9bc

diff --git a/sc/source/filter/oox/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx
index 071b9a6..dce942c 100644
--- a/sc/source/filter/oox/workbookhelper.cxx
+++ b/sc/source/filter/oox/workbookhelper.cxx
@@ -591,11 +591,6 @@ void WorkbookGlobals::finalize()
         // #i79826# enable updating automatic row height after loading the document
         aPropSet.setProperty( PROP_IsAdjustHeightEnabled, true );
 
-        getFormulaBuffer().finalizeImport();
-
-        // hack, setting it true the second time will delete the cache
-        aPropSet.setProperty( PROP_IsAdjustHeightEnabled, true );
-
         // Insert all pivot tables. Must be done after loading all sheets and
         // formulas, because data pilots expect existing source data on
         // creation.
@@ -667,6 +662,8 @@ void WorkbookHelper::finalizeWorkbookImport()
     mrBookGlob.getWorkbookSettings().finalizeImport();
     mrBookGlob.getViewSettings().finalizeImport();
 
+    // need to import formulas before scenarios
+    mrBookGlob.getFormulaBuffer().finalizeImport();
     /*  Insert scenarios after all sheet processing is done, because new hidden
         sheets are created for scenarios which would confuse code that relies
         on certain sheet indexes. Must be done after pivot tables too. */
commit c1638e418cfdffabef93bb358dcdd3ae239e3bcd
Author: Noel Power <noel.power at suse.com>
Date:   Thu Dec 13 16:26:58 2012 +0000

    fix fdo#58237 import hyperlinks for shapes in xlsx documents
    
    Change-Id: Ib0c661dbb3ce9a2f8c8d29707a1cf0c65aadc81f

diff --git a/oox/inc/oox/core/relations.hxx b/oox/inc/oox/core/relations.hxx
index e7d558b..67f298e 100644
--- a/oox/inc/oox/core/relations.hxx
+++ b/oox/inc/oox/core/relations.hxx
@@ -88,6 +88,8 @@ public:
 
     /** Returns the external target of the relation with the passed relation identifier. */
     ::rtl::OUString     getExternalTargetFromRelId( const ::rtl::OUString& rRelId ) const;
+    /** Returns the internal target of the relation with the passed relation identifier. */
+    ::rtl::OUString     getInternalTargetFromRelId( const ::rtl::OUString& rRelId ) const;
 
     /** Returns the full fragment path for the target of the passed relation. */
     ::rtl::OUString     getFragmentPathFromRelation( const Relation& rRelation ) const;
diff --git a/oox/source/core/relations.cxx b/oox/source/core/relations.cxx
index ef9510c..ad39489 100644
--- a/oox/source/core/relations.cxx
+++ b/oox/source/core/relations.cxx
@@ -92,6 +92,12 @@ OUString Relations::getExternalTargetFromRelId( const OUString& rRelId ) const
     return (pRelation && pRelation->mbExternal) ? pRelation->maTarget : OUString();
 }
 
+OUString Relations::getInternalTargetFromRelId( const OUString& rRelId ) const
+{
+    const Relation* pRelation = getRelationFromRelId( rRelId );
+    return (pRelation && !pRelation->mbExternal) ? pRelation->maTarget : OUString();
+}
+
 OUString Relations::getFragmentPathFromRelation( const Relation& rRelation ) const
 {
     // no target, no fragment path
diff --git a/oox/source/drawingml/hyperlinkcontext.cxx b/oox/source/drawingml/hyperlinkcontext.cxx
index 06958aa..ed03ddd 100644
--- a/oox/source/drawingml/hyperlinkcontext.cxx
+++ b/oox/source/drawingml/hyperlinkcontext.cxx
@@ -59,6 +59,11 @@ HyperLinkContext::HyperLinkContext( ContextHandler& rParent,
             OSL_TRACE("OOX: URI href %s", ::rtl::OUStringToOString (sHref, RTL_TEXTENCODING_UTF8).pData->buffer);
             sURL = getFilter().getAbsoluteUrl( sHref );
         }
+        else
+        {
+            // not sure if we also need to set sHref to the internal target
+            sURL = getRelations().getInternalTargetFromRelId( aRelId );
+        }
     }
     OUString sTooltip = xAttributes->getOptionalValue( R_TOKEN( tooltip ) );
     if ( !sTooltip.isEmpty() )
diff --git a/sc/source/filter/inc/worksheetbuffer.hxx b/sc/source/filter/inc/worksheetbuffer.hxx
index e527a72..3402518 100644
--- a/sc/source/filter/inc/worksheetbuffer.hxx
+++ b/sc/source/filter/inc/worksheetbuffer.hxx
@@ -90,6 +90,10 @@ public:
     sal_Int16           getCalcSheetIndex( const ::rtl::OUString& rWorksheetName ) const;
     /** Returns the finalized name of the sheet with the passed worksheet name. */
     ::rtl::OUString     getCalcSheetName( const ::rtl::OUString& rWorksheetName ) const;
+    /** Converts sSheetNameRef (e.g. '#SheetName!A1' to '#SheetName.A1' )
+        if sSheetNameRef doesn't start with '#' it is ignored and not modified
+    */
+    void                convertSheetNameRef( ::rtl::OUString& sSheetNameRef ) const;
 
 private:
     struct SheetInfo : public SheetInfoModel
diff --git a/sc/source/filter/oox/drawingfragment.cxx b/sc/source/filter/oox/drawingfragment.cxx
index 73e6b47..6e8dc5e 100644
--- a/sc/source/filter/oox/drawingfragment.cxx
+++ b/sc/source/filter/oox/drawingfragment.cxx
@@ -35,6 +35,9 @@
 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
 #include <com/sun/star/script/XEventAttacherManager.hpp>
 #include <rtl/strbuf.hxx>
+#include <svx/svdobj.hxx>
+#include "drwlayer.hxx"
+#include "userdat.hxx"
 #include "oox/drawingml/connectorshapecontext.hxx"
 #include "oox/drawingml/graphicshapecontext.hxx"
 #include "oox/helper/attributelist.hxx"
@@ -45,7 +48,7 @@
 #include "stylesbuffer.hxx"
 #include "themebuffer.hxx"
 #include "unitconverter.hxx"
-
+#include "worksheetbuffer.hxx"
 namespace oox {
 namespace xls {
 
@@ -66,6 +69,10 @@ using namespace ::oox::core;
 using namespace ::oox::drawingml;
 using namespace ::oox::ole;
 
+using ::com::sun::star::awt::Size;
+using ::com::sun::star::awt::Point;
+using ::com::sun::star::awt::Rectangle;
+using ::com::sun::star::awt::XControlModel;
 using ::rtl::OStringBuffer;
 using ::rtl::OUString;
 using ::rtl::OUStringToOString;
@@ -110,12 +117,24 @@ Shape::Shape( const WorksheetHelper& rHelper, const AttributeList& rAttribs, con
 
 void Shape::finalizeXShape( XmlFilterBase& rFilter, const Reference< XShapes >& rxShapes )
 {
+    rtl::OUString sURL;
+    getShapeProperties()[ PROP_URL ] >>= sURL;
+    getWorksheets().convertSheetNameRef( sURL );
     if( !maMacroName.isEmpty() && mxShape.is() )
     {
         VbaMacroAttacherRef xAttacher( new ShapeMacroAttacher( maMacroName, mxShape ) );
         getBaseFilter().getVbaProject().registerMacroAttacher( xAttacher );
     }
     ::oox::drawingml::Shape::finalizeXShape( rFilter, rxShapes );
+    if ( !sURL.isEmpty() )
+    {
+        SdrObject* pObj = SdrObject::getSdrObjectFromXShape( mxShape );
+        if ( pObj )
+        {
+            if ( ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj, sal_True ) )
+                pInfo->SetHlink( sURL );
+        }
+    }
 }
 
 // ============================================================================
diff --git a/sc/source/filter/oox/worksheetbuffer.cxx b/sc/source/filter/oox/worksheetbuffer.cxx
index 8e092ac..f315eeb 100644
--- a/sc/source/filter/oox/worksheetbuffer.cxx
+++ b/sc/source/filter/oox/worksheetbuffer.cxx
@@ -119,6 +119,25 @@ OUString WorksheetBuffer::getCalcSheetName( sal_Int32 nWorksheet ) const
     return pSheetInfo ? pSheetInfo->maCalcName : OUString();
 }
 
+void WorksheetBuffer::convertSheetNameRef( ::rtl::OUString& sSheetNameRef ) const
+{
+    // convert '#SheetName!A1' to '#SheetName.A1'
+    if( !sSheetNameRef.isEmpty() && (sSheetNameRef[ 0 ] == '#') )
+    {
+        sal_Int32 nSepPos = sSheetNameRef.lastIndexOf( '!' );
+        if( nSepPos > 0 )
+        {
+            // replace the exclamation mark with a period
+            sSheetNameRef = sSheetNameRef.replaceAt( nSepPos, 1, OUString( sal_Unicode( '.' ) ) );
+            // #i66592# convert sheet names that have been renamed on import
+            OUString aSheetName = sSheetNameRef.copy( 1, nSepPos - 1 );
+            OUString aCalcName = getCalcSheetName( aSheetName );
+            if( !aCalcName.isEmpty() )
+                sSheetNameRef = sSheetNameRef.replaceAt( 1, nSepPos - 1, aCalcName );
+        }
+    }
+}
+
 sal_Int16 WorksheetBuffer::getCalcSheetIndex( const OUString& rWorksheetName ) const
 {
     const SheetInfo* pSheetInfo = maSheetInfosByName.get( rWorksheetName ).get();


More information about the Libreoffice-commits mailing list