[Libreoffice-commits] core.git: 7 commits - include/oox oox/source sc/qa sc/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Wed May 27 11:43:10 PDT 2015
include/oox/export/shapes.hxx | 13 +++
oox/source/export/drawingml.cxx | 32 ++++-----
oox/source/export/shapes.cxx | 79 +++++++++++++++--------
sc/qa/unit/data/xlsx/hyperlink.xlsx |binary
sc/qa/unit/subsequent_export-test.cxx | 15 ++++
sc/source/filter/excel/xeescher.cxx | 4 -
sc/source/filter/inc/xcl97esc.hxx | 2
sc/source/filter/inc/xcl97rec.hxx | 4 -
sc/source/filter/inc/xeescher.hxx | 2
sc/source/filter/xcl97/xcl97esc.cxx | 14 ++--
sc/source/filter/xcl97/xcl97rec.cxx | 114 +++++++++++++++++++++++++++++++++-
sc/source/ui/view/tabvwsh3.cxx | 38 ++++++++---
12 files changed, 251 insertions(+), 66 deletions(-)
New commits:
commit 4a882796f0f22f365ce28612b4553115ca76f256
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed May 27 20:33:26 2015 +0200
disable more annoying log output
Change-Id: I9f50b991defe7e241a66a0d52af24c9912508d26
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 55e87e9..c7af2b8 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -626,8 +626,8 @@ void DrawingML::WriteOutline( Reference<XPropertySet> rXPropSet )
cap = "rnd";
}
- DBG(fprintf(stderr, "dash dots: %d dashes: %d dotlen: %d dashlen: %d distance: %d\n",
- int( aLineDash.Dots ), int( aLineDash.Dashes ), int( aLineDash.DotLen ), int( aLineDash.DashLen ), int( aLineDash.Distance )));
+ SAL_INFO("oox.shape", "dash dots: " << aLineDash.Dots << " dashes: " << aLineDash.Dashes
+ << " dotlen: " << aLineDash.DotLen << " dashlen: " << aLineDash.DashLen << " distance: " << aLineDash.Distance);
}
/* fallthru intended */
case drawing::LineStyle_SOLID:
@@ -778,7 +778,7 @@ OUString DrawingML::WriteImage( const OUString& rURL, bool bRelPathToMedia )
if ( index != -1 )
{
- DBG(fprintf (stderr, "begin: %ld %s\n", long( sizeof( aURLBegin ) ), USS( rURL ) + RTL_CONSTASCII_LENGTH( aURLBegin ) ));
+ SAL_INFO("oox.shape", "begin: " << sizeof( aURLBegin ) << " " << USS( rURL ) + RTL_CONSTASCII_LENGTH( aURLBegin ));
Graphic aGraphic = GraphicObject( aURLBS.copy(RTL_CONSTASCII_LENGTH(aURLBegin)) ).GetTransformedGraphic ();
return WriteImage( aGraphic , bRelPathToMedia );
@@ -960,7 +960,7 @@ void DrawingML::WriteBlipMode( Reference< XPropertySet > rXPropSet, const OUStri
if (GetProperty( rXPropSet, "FillBitmapMode" ) )
mAny >>= eBitmapMode;
- DBG(fprintf(stderr, "fill bitmap mode: %d\n", eBitmapMode));
+ SAL_INFO("oox.shape", "fill bitmap mode: " << int(eBitmapMode));
switch (eBitmapMode)
{
@@ -1008,7 +1008,7 @@ void DrawingML::WriteBlipFill( Reference< XPropertySet > rXPropSet, const OUStri
{
if ( !sBitmapURL.isEmpty() )
{
- DBG(fprintf (stderr, "URL: %s\n", OUStringToOString( sBitmapURL, RTL_TEXTENCODING_UTF8 ).getStr() ));
+ SAL_INFO("oox.shape", "URL: " << sBitmapURL);
mpFS->startElementNS( nXmlNamespace , XML_blipFill, FSEND );
@@ -1135,7 +1135,7 @@ void DrawingML::WriteTransformation( const Rectangle& rRect,
void DrawingML::WriteShapeTransformation( Reference< XShape > rXShape, sal_Int32 nXmlNamespace, bool bFlipH, bool bFlipV, bool bSuppressRotation )
{
- DBG(fprintf(stderr, "write shape transformation\n" ));
+ SAL_INFO("oox.shape", "write shape transformation");
sal_Int32 nRotation=0;
awt::Point aPos = rXShape->getPosition();
@@ -1352,7 +1352,7 @@ void DrawingML::WriteRunProperties( Reference< XPropertySet > rRun, bool bIsFiel
if( GETAD( CharColor ) )
{
sal_uInt32 color = *static_cast<sal_uInt32 const *>(mAny.getValue());
- DBG(fprintf(stderr, "run color: %x auto: %x\n", static_cast<unsigned int>( color ), static_cast<unsigned int>( COL_AUTO )));
+ SAL_INFO("oox.shape", "run color: " << color << " auto: " << COL_AUTO);
if( color == COL_AUTO ) // nCharColor depends to the background color
{
@@ -1445,7 +1445,7 @@ const char* DrawingML::GetFieldType( ::com::sun::star::uno::Reference< ::com::su
if( GETA( TextPortionType ) )
{
aFieldType = OUString( *static_cast<OUString const *>(mAny.getValue()) );
- DBG(fprintf (stderr, "field type: %s\n", USS(aFieldType) ));
+ SAL_INFO("oox.shape", "field type: " << aFieldType);
}
if( aFieldType == "TextField" )
@@ -1459,7 +1459,7 @@ const char* DrawingML::GetFieldType( ::com::sun::star::uno::Reference< ::com::su
if( rXPropSet.is() )
{
OUString aFieldKind( rXTextField->getPresentation( true ) );
- DBG(fprintf (stderr, "field kind: %s\n", USS(aFieldKind) ));
+ SAL_INFO("oox.shape", "field kind: " << aFieldKind);
if( aFieldKind == "Page" )
{
return "slidenum";
@@ -1626,7 +1626,7 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa
if (!(mAny >>= rXIndexAccess) || nLevel >= rXIndexAccess->getCount())
return;
- DBG(fprintf (stderr, "numbering rules\n"));
+ SAL_INFO("oox.shape", "numbering rules");
Sequence<PropertyValue> aPropertySequence;
rXIndexAccess->getByIndex(nLevel) >>= aPropertySequence;
@@ -1656,7 +1656,7 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa
if ( pValue )
{
OUString aPropName( pPropValue[ i ].Name );
- DBG(fprintf (stderr, "pro name: %s\n", OUStringToOString( aPropName, RTL_TEXTENCODING_UTF8 ).getStr()));
+ SAL_INFO("oox.shape", "pro name: " << aPropName);
if ( aPropName == "NumberingType" )
{
nNumberingType = *( static_cast<sal_Int16 const *>(pValue) );
@@ -1705,7 +1705,7 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa
else if ( aPropName == "GraphicURL" )
{
aGraphicURL = *static_cast<OUString const *>(pValue);
- DBG(fprintf (stderr, "graphic url: %s\n", OUStringToOString( aGraphicURL, RTL_TEXTENCODING_UTF8 ).getStr()));
+ SAL_INFO("oox.shape", "graphic url: " << aGraphicURL);
}
else if ( aPropName == "GraphicSize" )
{
@@ -1716,7 +1716,7 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa
pPropValue[ i ].Value >>= aSize;
//aBuGraSize.nA = aSize.Width;
//aBuGraSize.nB = aSize.Height;
- DBG(fprintf(stderr, "graphic size: %dx%d\n", int( aSize.Width ), int( aSize.Height )));
+ SAL_INFO("oox.shape", "graphic size: " << aSize.Width << "x" << aSize.Height);
}
}
}
@@ -1778,7 +1778,7 @@ sal_Int32 DrawingML::getBulletMarginIndentation (Reference< XPropertySet > rXPro
if (!(mAny >>= rXIndexAccess) || nLevel >= rXIndexAccess->getCount())
return 0;
- DBG(fprintf (stderr, "numbering rules\n"));
+ SAL_INFO("oox.shape", "numbering rules");
Sequence<PropertyValue> aPropertySequence;
rXIndexAccess->getByIndex(nLevel) >>= aPropertySequence;
@@ -1796,7 +1796,7 @@ sal_Int32 DrawingML::getBulletMarginIndentation (Reference< XPropertySet > rXPro
if ( pValue )
{
OUString aPropName( pPropValue[ i ].Name );
- DBG(fprintf (stderr, "pro name: %s\n", OUStringToOString( aPropName, RTL_TEXTENCODING_UTF8 ).getStr()));
+ SAL_INFO("oox.shape", "pro name: " << aPropName);
if ( aPropName == propName )
return *( static_cast<sal_Int32 const *>(pValue) );
}
@@ -2172,7 +2172,7 @@ void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, bool b
&& OString(pShape) != "rect" //some shape types are commented out in pCustomShapeTypeTranslationTable[] & are being defaulted to rect & rect does not have adjustment values/name.
)
{
- DBG(fprintf(stderr, "adj seq len: %d\n", int( aAdjustmentSeq.getLength() )));
+ SAL_INFO("oox.shape", "adj seq len: " << aAdjustmentSeq.getLength());
if ( bPredefinedHandlesUsed )
EscherPropertyContainer::LookForPolarHandles( eShapeType, nAdjustmentsWhichNeedsToBeConverted );
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 186f280..0f2b9ed 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -959,11 +959,11 @@ static const NameToConvertMapType& lcl_GetConverters(DrawingML::DocumentType eDo
ShapeExport& ShapeExport::WriteShape( Reference< XShape > xShape )
{
OUString sShapeType = xShape->getShapeType();
- DBG( fprintf( stderr, "write shape: %s\n", USS( sShapeType ) ) );
+ SAL_INFO("oox.shape", "write shape: " << sShapeType);
NameToConvertMapType::const_iterator aConverter = lcl_GetConverters(GetDocumentType()).find( USS( sShapeType ) );
if( aConverter == lcl_GetConverters(GetDocumentType()).end() )
{
- DBG( fprintf( stderr, "unknown shape\n" ) );
+ SAL_INFO("oox.shape", "unknown shape");
return WriteUnknownShape( xShape );
}
(this->*(aConverter->second))( xShape );
commit 106a4dc29980889c02faa526e5417b63fdce6c23
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed May 27 20:24:28 2015 +0200
support R1C1 reference for hyperlinks
Change-Id: Id9f3ae613128bb6f3895ade8b10ae24210439503
diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx
index 46deb7e..f3e0af3 100644
--- a/sc/source/filter/xcl97/xcl97rec.cxx
+++ b/sc/source/filter/xcl97/xcl97rec.cxx
@@ -1065,7 +1065,12 @@ sal_uInt16 parseRange(const OUString& rString, ScRange& rRange, ScDocument* pDoc
return nResult;
// try excel a1
- return rRange.Parse(rString, pDoc, formula::FormulaGrammar::CONV_XL_A1);
+ nResult = rRange.Parse(rString, pDoc, formula::FormulaGrammar::CONV_XL_A1);
+ if (nResult & SCA_VALID)
+ return nResult;
+
+ // try r1c1
+ return rRange.Parse(rString, pDoc, formula::FormulaGrammar::CONV_XL_R1C1);
}
sal_uInt16 parseAddress(const OUString& rString, ScAddress& rAddress, ScDocument* pDoc)
@@ -1082,7 +1087,12 @@ sal_uInt16 parseAddress(const OUString& rString, ScAddress& rAddress, ScDocument
return nResult;
// try excel a1
- return rAddress.Parse(rString, pDoc, formula::FormulaGrammar::CONV_XL_A1);
+ nResult = rAddress.Parse(rString, pDoc, formula::FormulaGrammar::CONV_XL_A1);
+ if ( (nResult & SCA_VALID) )
+ return nResult;
+
+ // try r1c1
+ return rAddress.Parse(rString, pDoc, formula::FormulaGrammar::CONV_XL_R1C1);
}
bool transformURL(const OUString& rOldURL, OUString& rNewURL, ScDocument* pDoc)
diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx
index 30972e6..8fdce44 100644
--- a/sc/source/ui/view/tabvwsh3.cxx
+++ b/sc/source/ui/view/tabvwsh3.cxx
@@ -82,8 +82,13 @@ static sal_uInt16 lcl_ParseRange(ScRange& rScRange, const OUString& aAddress, Sc
if ( (nResult & SCA_VALID) )
return nResult;
+ // try the default calc address convention
+ nResult = rScRange.Parse(aAddress, pDoc, formula::FormulaGrammar::CONV_XL_A1);
+ if ( (nResult & SCA_VALID) )
+ return nResult;
+
// try excel a1
- return rScRange.Parse(aAddress, pDoc, ScAddress::Details(formula::FormulaGrammar::CONV_XL_A1, 0, 0));
+ return rScRange.Parse(aAddress, pDoc, formula::FormulaGrammar::CONV_XL_R1C1);
}
static sal_uInt16 lcl_ParseAddress(ScAddress& rScAddress, const OUString& aAddress, ScDocument* pDoc, sal_uInt16 /* nSlot */)
@@ -99,8 +104,13 @@ static sal_uInt16 lcl_ParseAddress(ScAddress& rScAddress, const OUString& aAddre
if ( (nResult & SCA_VALID) )
return nResult;
+ // try the default calc address convention
+ nResult = rScAddress.Parse(aAddress, pDoc, formula::FormulaGrammar::CONV_XL_A1);
+ if ( (nResult & SCA_VALID) )
+ return nResult;
+
// try excel a1
- return rScAddress.Parse(aAddress, pDoc, ScAddress::Details(formula::FormulaGrammar::CONV_XL_A1, 0, 0));
+ return rScAddress.Parse(aAddress, pDoc, formula::FormulaGrammar::CONV_XL_R1C1);
}
void ScTabViewShell::Execute( SfxRequest& rReq )
commit 5142c9226318019200ed6e055b4eb1503bd002db
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed May 27 20:23:29 2015 +0200
add test for tdf#91334
Change-Id: Iaeee4a86e000445a23970986d5750d27adff2e2d
diff --git a/sc/qa/unit/data/xlsx/hyperlink.xlsx b/sc/qa/unit/data/xlsx/hyperlink.xlsx
new file mode 100644
index 0000000..059e649
Binary files /dev/null and b/sc/qa/unit/data/xlsx/hyperlink.xlsx differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 60b4b5c..3f0ea90 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -144,6 +144,7 @@ public:
void testTextUnderlineColor();
void testSheetRunParagraphProperty();
void testHiddenShape();
+ void testHyperlinkXLSX();
CPPUNIT_TEST_SUITE(ScExportTest);
CPPUNIT_TEST(test);
@@ -198,6 +199,7 @@ public:
CPPUNIT_TEST(testTextUnderlineColor);
CPPUNIT_TEST(testSheetRunParagraphProperty);
CPPUNIT_TEST(testHiddenShape);
+ CPPUNIT_TEST(testHyperlinkXLSX);
CPPUNIT_TEST_SUITE_END();
@@ -225,7 +227,8 @@ void ScExportTest::registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx)
{ BAD_CAST("text"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:text:1.0") },
{ BAD_CAST("xlink"), BAD_CAST("http://www.w3c.org/1999/xlink") },
{ BAD_CAST("xdr"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing") },
- { BAD_CAST("x"), BAD_CAST("http://schemas.openxmlformats.org/spreadsheetml/2006/main") }
+ { BAD_CAST("x"), BAD_CAST("http://schemas.openxmlformats.org/spreadsheetml/2006/main") },
+ { BAD_CAST("r"), BAD_CAST("http://schemas.openxmlformats.org/package/2006/relationships") }
};
for(size_t i = 0; i < SAL_N_ELEMENTS(aNamespaces); ++i)
{
@@ -2642,6 +2645,16 @@ void ScExportTest::testHiddenShape()
assertXPath(pDoc, "/xdr:wsDr/xdr:twoCellAnchor/xdr:sp[1]/xdr:nvSpPr/xdr:cNvPr", "hidden", "1");
}
+void ScExportTest::testHyperlinkXLSX()
+{
+ ScDocShellRef xDocSh = loadDoc("hyperlink.", XLSX);
+ CPPUNIT_ASSERT(xDocSh.Is());
+
+ xmlDocPtr pDoc = XPathHelper::parseExport(&(*xDocSh), m_xSFactory, "xl/drawings/_rels/drawing1.xml.rels", XLSX);
+ CPPUNIT_ASSERT(pDoc);
+ assertXPath(pDoc, "/r:Relationships/r:Relationship", "Target", "#Sheet2!A1");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
commit 5d33f6634c5fb84cb2a801d7819c8affb031cc02
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed May 27 19:15:12 2015 +0200
transform calc URLs to OOXML format, related tdf#91334
Change-Id: I497a6600e155200e913ed386a539f284a5c86320
diff --git a/include/oox/export/shapes.hxx b/include/oox/export/shapes.hxx
index c979b3f..eccda13 100644
--- a/include/oox/export/shapes.hxx
+++ b/include/oox/export/shapes.hxx
@@ -40,6 +40,16 @@ namespace drawing {
namespace oox { namespace drawingml {
+class OOX_DLLPUBLIC URLTransformer
+{
+public:
+ virtual ~URLTransformer();
+
+ virtual OUString getTransformedString(const OUString& rURL) const;
+
+ virtual bool isExternalURL(const OUString& rURL) const;
+};
+
class OOX_DLLPUBLIC ShapeExport : public DrawingML {
private:
@@ -69,6 +79,7 @@ private:
sal_Int32 mnXmlNamespace;
Fraction maFraction;
MapMode maMapModeSrc, maMapModeDest;
+ std::shared_ptr<URLTransformer> mpURLTransformer;
::com::sun::star::awt::Size MapSize( const ::com::sun::star::awt::Size& ) const;
@@ -81,6 +92,8 @@ public:
ShapeExport( sal_Int32 nXmlNamespace, ::sax_fastparser::FSHelperPtr pFS, ShapeHashMap* pShapeMap = NULL, ::oox::core::XmlFilterBase* pFB = NULL, DocumentType eDocumentType = DOCUMENT_PPTX, DMLTextExport* pTextExport = 0 );
virtual ~ShapeExport() {}
+ void SetURLTranslator(std::shared_ptr<URLTransformer> pTransformer);
+
static bool NonEmptyText( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xIface );
ShapeExport&
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index debb5b7..186f280 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -107,6 +107,20 @@ using ::sax_fastparser::FSHelperPtr;
namespace oox { namespace drawingml {
+URLTransformer::~URLTransformer()
+{
+}
+
+OUString URLTransformer::getTransformedString(const OUString& rString) const
+{
+ return rString;
+}
+
+bool URLTransformer::isExternalURL(const OUString& /*rURL*/) const
+{
+ return true;
+}
+
#define GETA(propName) \
GetProperty( rXPropSet, OUString(#propName))
@@ -130,6 +144,12 @@ ShapeExport::ShapeExport( sal_Int32 nXmlNamespace, FSHelperPtr pFS, ShapeHashMap
, maMapModeDest( MAP_INCH, Point(), maFraction, maFraction )
, mpShapeMap( pShapeMap ? pShapeMap : &maShapeMap )
{
+ mpURLTransformer.reset(new URLTransformer);
+}
+
+void ShapeExport::SetURLTranslator(std::shared_ptr<URLTransformer> pTransformer)
+{
+ mpURLTransformer = pTransformer;
}
awt::Size ShapeExport::MapSize( const awt::Size& rSize ) const
@@ -445,7 +465,8 @@ ShapeExport& ShapeExport::WriteCustomShape( Reference< XShape > xShape )
{
OUString sRelId = mpFB->addRelation( mpFS->getOutputStream(),
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
- sURL, true );
+ mpURLTransformer->getTransformedString(sURL),
+ mpURLTransformer->isExternalURL(sURL));
mpFS->singleElementNS( XML_a, XML_hlinkClick,
FSNS( XML_r,XML_id ), USS( sRelId ),
diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx
index 9caee24..c0d1cf0 100644
--- a/sc/source/filter/excel/xeescher.cxx
+++ b/sc/source/filter/excel/xeescher.cxx
@@ -1332,8 +1332,8 @@ XclMacroHelper::SetMacroLink( const OUString& rMacroName )
return false;
}
-XclExpShapeObj::XclExpShapeObj( XclExpObjectManager& rRoot, ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape ) :
- XclObjAny( rRoot, xShape ),
+XclExpShapeObj::XclExpShapeObj( XclExpObjectManager& rRoot, ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape, ScDocument* pDoc ) :
+ XclObjAny( rRoot, xShape, pDoc ),
XclMacroHelper( rRoot )
{
if( SdrObject* pSdrObj = ::GetSdrObjectFromXShape( xShape ) )
diff --git a/sc/source/filter/inc/xcl97esc.hxx b/sc/source/filter/inc/xcl97esc.hxx
index e5d1bd1..a101bef 100644
--- a/sc/source/filter/inc/xcl97esc.hxx
+++ b/sc/source/filter/inc/xcl97esc.hxx
@@ -58,7 +58,7 @@ class ShapeInteractionHelper
{
public:
static XclExpShapeObj* CreateShapeObj( XclExpObjectManager& rObjMgr, const ::com::sun::star::uno::Reference<
- ::com::sun::star::drawing::XShape >& xShape );
+ ::com::sun::star::drawing::XShape >& xShape, ScDocument* pDoc );
static void PopulateShapeInteractionInfo( XclExpObjectManager& rObjMgr, const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape, EscherExHostAppData& rHostAppData );
};
diff --git a/sc/source/filter/inc/xcl97rec.hxx b/sc/source/filter/inc/xcl97rec.hxx
index 222c5cb..5b1c744 100644
--- a/sc/source/filter/inc/xcl97rec.hxx
+++ b/sc/source/filter/inc/xcl97rec.hxx
@@ -250,7 +250,8 @@ protected:
public:
XclObjAny( XclExpObjectManager& rObjMgr,
- const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape );
+ const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape,
+ ScDocument* pDoc);
virtual ~XclObjAny();
com::sun::star::uno::Reference< com::sun::star::drawing::XShape >
@@ -264,6 +265,7 @@ public:
private:
com::sun::star::uno::Reference< com::sun::star::drawing::XShape >
mxShape;
+ ScDocument* mpDoc;
};
// --- class ExcBof8_Base --------------------------------------------
diff --git a/sc/source/filter/inc/xeescher.hxx b/sc/source/filter/inc/xeescher.hxx
index 56b183a..98e08d5 100644
--- a/sc/source/filter/inc/xeescher.hxx
+++ b/sc/source/filter/inc/xeescher.hxx
@@ -211,7 +211,7 @@ public:
class XclExpShapeObj : public XclObjAny, public XclMacroHelper
{
public:
- explicit XclExpShapeObj( XclExpObjectManager& rRoot, ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
+ explicit XclExpShapeObj( XclExpObjectManager& rRoot, ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape, ScDocument* pDoc );
virtual ~XclExpShapeObj();
private:
virtual void WriteSubRecs( XclExpStream& rStrm ) SAL_OVERRIDE;
diff --git a/sc/source/filter/xcl97/xcl97esc.cxx b/sc/source/filter/xcl97/xcl97esc.cxx
index 6bd7448..a17ac85 100644
--- a/sc/source/filter/xcl97/xcl97esc.cxx
+++ b/sc/source/filter/xcl97/xcl97esc.cxx
@@ -206,7 +206,7 @@ EscherExHostAppData* XclEscherEx::StartShape( const Reference< XShape >& rxShape
//added for exporting OCX control
sal_Int16 nMsCtlType = 0;
if ( !pObj )
- pCurrXclObj = new XclObjAny( mrObjMgr, rxShape ); // just what is it?!?
+ pCurrXclObj = new XclObjAny( mrObjMgr, rxShape, GetDocPtr() ); // just what is it?!?
else
{
pCurrXclObj = NULL;
@@ -231,10 +231,10 @@ EscherExHostAppData* XclEscherEx::StartShape( const Reference< XShape >& rxShape
pCurrXclObj = new XclObjOle( mrObjMgr, *pObj );
}
else // just a metafile
- pCurrXclObj = new XclObjAny( mrObjMgr, rxShape );
+ pCurrXclObj = new XclObjAny( mrObjMgr, rxShape, GetDocPtr() );
}
else
- pCurrXclObj = new XclObjAny( mrObjMgr, rxShape );
+ pCurrXclObj = new XclObjAny( mrObjMgr, rxShape, GetDocPtr() );
}
else if( nObjType == OBJ_UNO )
{
@@ -255,13 +255,13 @@ EscherExHostAppData* XclEscherEx::StartShape( const Reference< XShape >& rxShape
else //TBX Form Control
pCurrXclObj = CreateTBXCtrlObj( rxShape, pChildAnchor );
if( !pCurrXclObj )
- pCurrXclObj = new XclObjAny( mrObjMgr, rxShape ); // just a metafile
+ pCurrXclObj = new XclObjAny( mrObjMgr, rxShape, GetDocPtr() ); // just a metafile
}
else if( !ScDrawLayer::IsNoteCaption( pObj ) )
{
// ignore permanent note shapes
// #i12190# do not ignore callouts (do not filter by object type ID)
- pCurrXclObj = ShapeInteractionHelper::CreateShapeObj( mrObjMgr, rxShape );
+ pCurrXclObj = ShapeInteractionHelper::CreateShapeObj( mrObjMgr, rxShape, GetDocPtr() );
ShapeInteractionHelper::PopulateShapeInteractionInfo( mrObjMgr, rxShape, *pCurrAppData );
}
}
@@ -542,9 +542,9 @@ void XclEscherClientTextbox::WriteData( EscherEx& /*rEx*/ ) const
}
XclExpShapeObj*
-ShapeInteractionHelper::CreateShapeObj( XclExpObjectManager& rObjMgr, const Reference< XShape >& xShape )
+ShapeInteractionHelper::CreateShapeObj( XclExpObjectManager& rObjMgr, const Reference< XShape >& xShape, ScDocument* pDoc )
{
- return new XclExpShapeObj( rObjMgr, xShape );
+ return new XclExpShapeObj( rObjMgr, xShape, pDoc );
}
void
diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx
index ae8b93b..46deb7e 100644
--- a/sc/source/filter/xcl97/xcl97rec.cxx
+++ b/sc/source/filter/xcl97/xcl97rec.cxx
@@ -30,6 +30,7 @@
#include <editeng/writingmodeitem.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
+#include <tools/urlobj.hxx>
#include <rtl/math.hxx>
#include <svl/zformat.hxx>
@@ -956,9 +957,10 @@ void XclObjOle::Save( XclExpStream& rStrm )
// --- class XclObjAny -------------------------------------------
-XclObjAny::XclObjAny( XclExpObjectManager& rObjMgr, const Reference< XShape >& rShape )
+XclObjAny::XclObjAny( XclExpObjectManager& rObjMgr, const Reference< XShape >& rShape, ScDocument* pDoc )
: XclObj( rObjMgr, EXC_OBJTYPE_UNKNOWN )
, mxShape( rShape )
+ , mpDoc(pDoc)
{
}
@@ -1047,6 +1049,104 @@ GetEditAs( XclObjAny& rObj )
return "absolute";
}
+namespace {
+
+sal_uInt16 parseRange(const OUString& rString, ScRange& rRange, ScDocument* pDoc)
+{
+ // start with the address convention set in the document
+ formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ sal_uInt16 nResult = rRange.Parse(rString, pDoc, eConv);
+ if ( (nResult & SCA_VALID) )
+ return nResult;
+
+ // try the default calc address convention
+ nResult = rRange.Parse(rString, pDoc);
+ if ( (nResult & SCA_VALID) )
+ return nResult;
+
+ // try excel a1
+ return rRange.Parse(rString, pDoc, formula::FormulaGrammar::CONV_XL_A1);
+}
+
+sal_uInt16 parseAddress(const OUString& rString, ScAddress& rAddress, ScDocument* pDoc)
+{
+ // start with the address convention set in the document
+ formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ sal_uInt16 nResult = rAddress.Parse(rString, pDoc, eConv);
+ if ( (nResult & SCA_VALID) )
+ return nResult;
+
+ // try the default calc address convention
+ nResult = rAddress.Parse(rString, pDoc);
+ if ( (nResult & SCA_VALID) )
+ return nResult;
+
+ // try excel a1
+ return rAddress.Parse(rString, pDoc, formula::FormulaGrammar::CONV_XL_A1);
+}
+
+bool transformURL(const OUString& rOldURL, OUString& rNewURL, ScDocument* pDoc)
+{
+ if (rOldURL.startsWith("#"))
+ {
+ // URL has to be decoded for escaped characters (%20)
+ OUString aURL = INetURLObject::decode( rOldURL,
+ INetURLObject::DECODE_WITH_CHARSET,
+ RTL_TEXTENCODING_UTF8 );
+ OUString aAddressString = aURL.copy(1);
+
+ ScRange aRange;
+ ScAddress aAddress;
+ sal_uInt16 nResult = parseRange(aAddressString, aRange, pDoc);
+ if (nResult & SCA_VALID)
+ {
+ OUString aString = aRange.Format(nResult, pDoc, formula::FormulaGrammar::CONV_XL_OOX);
+ rNewURL = OUString("#") + aString;
+ return true;
+ }
+ else
+ {
+ nResult = parseAddress(aAddressString, aAddress, pDoc);
+ if(nResult & SCA_VALID)
+ {
+ OUString aString = aAddress.Format(nResult, pDoc, formula::FormulaGrammar::CONV_XL_OOX);
+ rNewURL = OUString("#") + aString;
+ return true;
+ }
+ }
+ }
+
+ rNewURL = rOldURL;
+ return false;
+}
+
+class ScURLTransformer : public oox::drawingml::URLTransformer
+{
+public:
+ ScURLTransformer(ScDocument& rDoc):
+ mrDoc(rDoc)
+ {
+ }
+
+ virtual OUString getTransformedString(const OUString& rURL) const SAL_OVERRIDE
+ {
+ OUString aNewURL;
+ transformURL(rURL, aNewURL, &mrDoc);
+ return aNewURL;
+ }
+
+ virtual bool isExternalURL(const OUString& rURL) const SAL_OVERRIDE
+ {
+ OUString aNewURL;
+ return transformURL(rURL, aNewURL, &mrDoc);
+ }
+
+private:
+ ScDocument& mrDoc;
+};
+
+}
+
void XclObjAny::SaveXml( XclExpXmlStream& rStrm )
{
// ignore group shapes at the moment, we don't process them correctly
@@ -1057,6 +1157,8 @@ void XclObjAny::SaveXml( XclExpXmlStream& rStrm )
sax_fastparser::FSHelperPtr pDrawing = rStrm.GetCurrentStream();
ShapeExport aDML( XML_xdr, pDrawing, NULL, &rStrm, DrawingML::DOCUMENT_XLSX );
+ std::shared_ptr<oox::drawingml::URLTransformer> pURLTransformer(new ScURLTransformer(*mpDoc));
+ aDML.SetURLTranslator(pURLTransformer);
pDrawing->startElement( FSNS( XML_xdr, XML_twoCellAnchor ), // OOXTODO: oneCellAnchor, absoluteAnchor
XML_editAs, GetEditAs( *this ),
commit 27dde67419e8418a79bab3eab4082c5e341dfd04
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed May 27 12:05:03 2015 +0200
first check current document address convention
Might be something else like R1C1
Change-Id: I25419b0d6ce0261b8cb1248671582455331852ac
diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx
index 88b2fc6..30972e6 100644
--- a/sc/source/ui/view/tabvwsh3.cxx
+++ b/sc/source/ui/view/tabvwsh3.cxx
@@ -69,25 +69,37 @@
#include <boost/scoped_ptr.hpp>
-/** Try to parse the given range using Calc-style syntax first, then
- Excel-style if that fails. */
static sal_uInt16 lcl_ParseRange(ScRange& rScRange, const OUString& aAddress, ScDocument* pDoc, sal_uInt16 /* nSlot */)
{
- sal_uInt16 nResult = rScRange.Parse(aAddress, pDoc);
+ // start with the address convention set in the document
+ formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ sal_uInt16 nResult = rScRange.Parse(aAddress, pDoc, eConv);
if ( (nResult & SCA_VALID) )
return nResult;
+ // try the default calc address convention
+ nResult = rScRange.Parse(aAddress, pDoc);
+ if ( (nResult & SCA_VALID) )
+ return nResult;
+
+ // try excel a1
return rScRange.Parse(aAddress, pDoc, ScAddress::Details(formula::FormulaGrammar::CONV_XL_A1, 0, 0));
}
-/** Try to parse the given address using Calc-style syntax first, then
- Excel-style if that fails. */
static sal_uInt16 lcl_ParseAddress(ScAddress& rScAddress, const OUString& aAddress, ScDocument* pDoc, sal_uInt16 /* nSlot */)
{
- sal_uInt16 nResult = rScAddress.Parse(aAddress, pDoc);
+ // start with the address convention set in the document
+ formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ sal_uInt16 nResult = rScAddress.Parse(aAddress, pDoc, eConv);
+ if ( (nResult & SCA_VALID) )
+ return nResult;
+
+ // try the default calc address convention
+ nResult = rScAddress.Parse(aAddress, pDoc);
if ( (nResult & SCA_VALID) )
return nResult;
+ // try excel a1
return rScAddress.Parse(aAddress, pDoc, ScAddress::Details(formula::FormulaGrammar::CONV_XL_A1, 0, 0));
}
commit 24c9f6664c41ebe6d58e261eb6a4beece4d85c76
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue May 26 18:57:11 2015 +0200
fix indentation
Change-Id: Ib686c76e024cccd33614f812e80ad6c16b5287e4
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 9810d3b..debb5b7 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -441,15 +441,16 @@ ShapeExport& ShapeExport::WriteCustomShape( Reference< XShape > xShape )
{
OUString sURL;
mAny >>= sURL;
- if( !sURL.isEmpty() ) {
- OUString sRelId = mpFB->addRelation( mpFS->getOutputStream(),
- "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
- sURL, true );
-
- mpFS->singleElementNS( XML_a, XML_hlinkClick,
- FSNS( XML_r,XML_id ), USS( sRelId ),
- FSEND );
- }
+ if( !sURL.isEmpty() )
+ {
+ OUString sRelId = mpFB->addRelation( mpFS->getOutputStream(),
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
+ sURL, true );
+
+ mpFS->singleElementNS( XML_a, XML_hlinkClick,
+ FSNS( XML_r,XML_id ), USS( sRelId ),
+ FSEND );
+ }
}
pFS->endElementNS(mnXmlNamespace, XML_cNvPr);
pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr, FSEND );
commit df7f469b46cdc012d7848bb5f4a6c51901bd3c52
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue May 26 17:55:11 2015 +0200
silence annoying log output
Change-Id: Ia2f55b85a649e0286573477511016f36bf29a9d5
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 2beec40..9810d3b 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -157,7 +157,7 @@ bool ShapeExport::NonEmptyText( Reference< XInterface > xIface )
bool bIsEmptyPresObj = false;
if ( xPropSet->getPropertyValue( "IsEmptyPresentationObject" ) >>= bIsEmptyPresObj )
{
- DBG(fprintf(stderr, "empty presentation object %d, props:\n", bIsEmptyPresObj));
+ SAL_INFO("oox.shape", "empty presentation object " << bIsEmptyPresObj << " , props:");
if( bIsEmptyPresObj )
return true;
}
@@ -168,7 +168,7 @@ bool ShapeExport::NonEmptyText( Reference< XInterface > xIface )
bool bIsPresObj = false;
if ( xPropSet->getPropertyValue( "IsPresentationObject" ) >>= bIsPresObj )
{
- DBG(fprintf(stderr, "presentation object %d, props:\n", bIsPresObj));
+ SAL_INFO("oox.shape", "presentation object " << bIsPresObj << ", props:");
if( bIsPresObj )
return true;
}
@@ -186,7 +186,7 @@ bool ShapeExport::NonEmptyText( Reference< XInterface > xIface )
ShapeExport& ShapeExport::WriteBezierShape( Reference< XShape > xShape, bool bClosed )
{
- DBG(fprintf(stderr, "write open bezier shape\n"));
+ SAL_INFO("oox.shape", "write open bezier shape");
FSHelperPtr pFS = GetFS();
pFS->startElementNS( mnXmlNamespace, (GetDocumentType() != DOCUMENT_DOCX ? XML_sp : XML_wsp), FSEND );
@@ -196,7 +196,8 @@ ShapeExport& ShapeExport::WriteBezierShape( Reference< XShape > xShape, bool bCl
#if OSL_DEBUG_LEVEL > 0
awt::Size size = MapSize( awt::Size( aRect.GetWidth(), aRect.GetHeight() ) );
- DBG(fprintf(stderr, "poly count %d\nsize: %d x %d", aPolyPolygon.Count(), int( size.Width ), int( size.Height )));
+ SAL_INFO("oox.shape", "poly count " << aPolyPolygon.Count());
+ SAL_INFO("oox.shape", "size: " << size.Width << " x " << size.Height);
#endif
// non visual shape properties
@@ -366,7 +367,7 @@ static bool lcl_IsOnWhitelist(OUString& rShapeType)
ShapeExport& ShapeExport::WriteCustomShape( Reference< XShape > xShape )
{
- DBG(fprintf(stderr, "write custom shape\n"));
+ SAL_INFO("oox.shape", "write custom shape");
Reference< XPropertySet > rXPropSet( xShape, UNO_QUERY );
bool bPredefinedHandlesUsed = true;
@@ -377,7 +378,7 @@ ShapeExport& ShapeExport::WriteCustomShape( Reference< XShape > xShape )
SdrObjCustomShape* pShape = static_cast<SdrObjCustomShape*>( GetSdrObjectFromXShape( xShape ) );
bool bIsDefaultObject = EscherPropertyContainer::IsDefaultObject( pShape, eShapeType );
const char* sPresetShape = msfilter::util::GetOOXMLPresetGeometry( USS( sShapeType ) );
- DBG(fprintf(stderr, "custom shape type: %s ==> %s\n", USS( sShapeType ), sPresetShape));
+ SAL_INFO("oox.shape", "custom shape type: " << sShapeType << " ==> " << sPresetShape);
Sequence< PropertyValue > aGeometrySeq;
sal_Int32 nAdjustmentValuesIndex = -1;
@@ -385,13 +386,13 @@ ShapeExport& ShapeExport::WriteCustomShape( Reference< XShape > xShape )
bool bFlipV = false;
if( GETA( CustomShapeGeometry ) ) {
- DBG(fprintf(stderr, "got custom shape geometry\n"));
+ SAL_INFO("oox.shape", "got custom shape geometry");
if( mAny >>= aGeometrySeq ) {
- DBG(fprintf(stderr, "got custom shape geometry sequence\n"));
+ SAL_INFO("oox.shape", "got custom shape geometry sequence");
for( int i = 0; i < aGeometrySeq.getLength(); i++ ) {
const PropertyValue& rProp = aGeometrySeq[ i ];
- DBG(fprintf(stderr, "geometry property: %s\n", USS( rProp.Name )));
+ SAL_INFO("oox.shape", "geometry property: " << rProp.Name);
if ( rProp.Name == "MirroredX" )
rProp.Value >>= bFlipH;
@@ -526,7 +527,7 @@ ShapeExport& ShapeExport::WriteCustomShape( Reference< XShape > xShape )
ShapeExport& ShapeExport::WriteEllipseShape( Reference< XShape > xShape )
{
- DBG(fprintf(stderr, "write ellipse shape\n"));
+ SAL_INFO("oox.shape", "write ellipse shape");
FSHelperPtr pFS = GetFS();
@@ -578,7 +579,7 @@ ShapeExport& ShapeExport::WriteGraphicObjectShape( Reference< XShape > xShape )
void ShapeExport::WriteGraphicObjectShapePart( Reference< XShape > xShape, const Graphic* pGraphic )
{
- DBG(fprintf(stderr, "write graphic object shape\n"));
+ SAL_INFO("oox.shape", "write graphic object shape");
if( NonEmptyText( xShape ) )
{
@@ -587,7 +588,7 @@ void ShapeExport::WriteGraphicObjectShapePart( Reference< XShape > xShape, const
if( xText.is() && xText->getString().getLength() )
{
- DBG(fprintf(stderr, "graphicObject: wrote only text\n"));
+ SAL_INFO("oox.shape", "graphicObject: wrote only text");
WriteTextShape( xShape );
@@ -596,13 +597,13 @@ void ShapeExport::WriteGraphicObjectShapePart( Reference< XShape > xShape, const
}
}
- DBG(fprintf(stderr, "graphicObject without text\n"));
+ SAL_INFO("oox.shape", "graphicObject without text");
OUString sGraphicURL;
Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY );
if( !pGraphic && ( !xShapeProps.is() || !( xShapeProps->getPropertyValue( "GraphicURL" ) >>= sGraphicURL ) ) )
{
- DBG(fprintf(stderr, "no graphic URL found\n"));
+ SAL_INFO("oox.shape", "no graphic URL found");
return;
}
@@ -677,7 +678,7 @@ ShapeExport& ShapeExport::WriteConnectorShape( Reference< XShape > xShape )
bool bFlipH = false;
bool bFlipV = false;
- DBG(fprintf(stderr, "write connector shape\n"));
+ SAL_INFO("oox.shape", "write connector shape");
FSHelperPtr pFS = GetFS();
@@ -768,7 +769,7 @@ ShapeExport& ShapeExport::WriteLineShape( Reference< XShape > xShape )
bool bFlipH = false;
bool bFlipV = false;
- DBG(fprintf(stderr, "write line shape\n"));
+ SAL_INFO("oox.shape", "write line shape");
FSHelperPtr pFS = GetFS();
@@ -839,7 +840,7 @@ ShapeExport& ShapeExport::WriteNonVisualProperties( Reference< XShape > )
ShapeExport& ShapeExport::WriteRectangleShape( Reference< XShape > xShape )
{
- DBG(fprintf(stderr, "write rectangle shape\n"));
+ SAL_INFO("oox.shape", "write rectangle shape");
FSHelperPtr pFS = GetFS();
More information about the Libreoffice-commits
mailing list