summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2012-12-13 16:26:58 +0000
committerNoel Power <noel.power@suse.com>2012-12-14 11:57:01 +0000
commitc1638e418cfdffabef93bb358dcdd3ae239e3bcd (patch)
treea4c4de8c7a6fcc200cd83724d3f9ae5e008fc7f1 /sc
parente873bb38c2df729d8662d1b1a13d85ad98aa6950 (diff)
fix fdo#58237 import hyperlinks for shapes in xlsx documents
Change-Id: Ib0c661dbb3ce9a2f8c8d29707a1cf0c65aadc81f
Diffstat (limited to 'sc')
-rw-r--r--sc/source/filter/inc/worksheetbuffer.hxx4
-rw-r--r--sc/source/filter/oox/drawingfragment.cxx21
-rw-r--r--sc/source/filter/oox/worksheetbuffer.cxx19
3 files changed, 43 insertions, 1 deletions
diff --git a/sc/source/filter/inc/worksheetbuffer.hxx b/sc/source/filter/inc/worksheetbuffer.hxx
index e527a72e40db..3402518ae760 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 73e6b47eb7c1..6e8dc5ed5c90 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 8e092ac74e5e..f315eebda2f1 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();