summaryrefslogtreecommitdiff
path: root/sc/source/ui/view
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2013-01-08 10:56:44 +0000
committerNoel Power <noel.power@suse.com>2013-01-08 11:01:04 +0000
commit92afb61d8bb1b264a945371065115981ecaed0f1 (patch)
tree454f19151a53e096740b1d5af032240679dc6bc9 /sc/source/ui/view
parenteb54843c8556cd39efb4ade347652ad118c5de66 (diff)
support new hyperlink cell attribute
Allows a hyperlink attribute to be set for a cell, allows for import of say a hyperlink associated with a formula cell. Since this patch does not add any file format support it is not possible to save such an imported hyperlink to ods. Note: such a hyperlink would not have been imported in the past so this should not be an issue Change-Id: Ieb234bb6e98e4a2630b596a90972a75be12a92d4
Diffstat (limited to 'sc/source/ui/view')
-rw-r--r--sc/source/ui/view/gridwin.cxx40
1 files changed, 28 insertions, 12 deletions
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 620d625f8dfc..96edbcbac3a2 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -378,7 +378,7 @@ static void lcl_UnLockComment( ScDrawView* pView, SdrPageView* pPV, SdrModel* pD
}
}
-static sal_Bool lcl_GetHyperlinkCell(ScDocument* pDoc, SCCOL& rPosX, SCROW& rPosY, SCTAB nTab, ScBaseCell*& rpCell )
+static sal_Bool lcl_GetHyperlinkCell(ScDocument* pDoc, SCCOL& rPosX, SCROW& rPosY, SCTAB nTab, ScBaseCell*& rpCell, OUString& rURL )
{
sal_Bool bFound = false;
do
@@ -391,13 +391,22 @@ static sal_Bool lcl_GetHyperlinkCell(ScDocument* pDoc, SCCOL& rPosX, SCROW& rPos
else
--rPosX; // weitersuchen
}
- else if ( rpCell->GetCellType() == CELLTYPE_EDIT)
- bFound = sal_True;
- else if (rpCell->GetCellType() == CELLTYPE_FORMULA &&
- static_cast<ScFormulaCell*>(rpCell)->IsHyperLinkCell())
- bFound = sal_True;
else
- return false; // andere Zelle
+ {
+ const ScPatternAttr* pPattern = pDoc->GetPattern( rPosX, rPosY, nTab );
+ if ( ((SfxStringItem&)pPattern->GetItem(ATTR_HYPERLINK)).GetValue().Len() > 0 )
+ {
+ rURL = ((SfxStringItem&)pPattern->GetItem(ATTR_HYPERLINK)).GetValue();
+ bFound = true;
+ }
+ else if ( rpCell->GetCellType() == CELLTYPE_EDIT)
+ bFound = sal_True;
+ else if (rpCell->GetCellType() == CELLTYPE_FORMULA &&
+ static_cast<ScFormulaCell*>(rpCell)->IsHyperLinkCell())
+ bFound = sal_True;
+ else
+ return false; // andere Zelle
+ }
}
while ( !bFound );
@@ -2305,7 +2314,8 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt )
SCTAB nTab = pViewData->GetTabNo();
pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
ScBaseCell* pCell = NULL;
- if( lcl_GetHyperlinkCell( pDoc, nPosX, nPosY, nTab, pCell ) )
+ OUString sURL;
+ if( lcl_GetHyperlinkCell( pDoc, nPosX, nPosY, nTab, pCell, sURL ) )
{
ScAddress aCellPos( nPosX, nPosY, nTab );
uno::Reference< table::XCell > xCell( new ScCellObj( pViewData->GetDocShell(), aCellPos ) );
@@ -5016,8 +5026,8 @@ bool ScGridWindow::GetEditUrlOrError( bool bSpellErr, const Point& rPos,
ScDocShell* pDocSh = pViewData->GetDocShell();
ScDocument* pDoc = pDocSh->GetDocument();
ScBaseCell* pCell = NULL;
-
- sal_Bool bFound = lcl_GetHyperlinkCell( pDoc, nPosX, nPosY, nTab, pCell );
+ OUString sURL;
+ sal_Bool bFound = lcl_GetHyperlinkCell( pDoc, nPosX, nPosY, nTab, pCell, sURL );
if( !bFound )
return false;
@@ -5094,9 +5104,15 @@ bool ScGridWindow::GetEditUrlOrError( bool bSpellErr, const Point& rPos,
if (pData)
aEngine.SetText(*pData);
}
- else // HyperLink Formula cell
+ else // Not an Edit cell and is a formula cell with 'Hyperlink'
+ // function if we have no URL, otherwise it could be a formula
+ // cell ( or other type ? ) with a hyperlink associated with it.
{
- pTextObj.reset((static_cast<ScFormulaCell*>(pCell))->CreateURLObject());
+ if ( sURL.isEmpty() )
+ pTextObj.reset((static_cast<ScFormulaCell*>(pCell))->CreateURLObject());
+ else
+ pTextObj.reset( ScBaseCell::CreateURLObjectFromURL( *pDoc, sURL, sURL ) );
+
if (pTextObj.get())
aEngine.SetText(*pTextObj);
}