diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2013-03-19 13:41:19 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-03-19 15:39:54 +0100 |
commit | df3ec1cd965bc6f34846cd86f303f3473e672031 (patch) | |
tree | d7571ab3a821658fd3a59bd7b62de0719b6db2b8 | |
parent | WaE: Werror=shadow (diff) | |
download | core-df3ec1cd965bc6f34846cd86f303f3473e672031.tar.gz core-df3ec1cd965bc6f34846cd86f303f3473e672031.zip |
bnc#802888 SwPageFrm: let macro fields have priority over background objects
The intention is to get similar behavior as
61f467c8974d6b6face41e7027d75ae4ddb6fdb2, except this applies to single
clicks, while that one affected only double-click.
Change-Id: Idddc26aa8cd064f89fb4f99b3ad7a5430ac455bc
(cherry picked from commits a996678ed30804e16103e1cfdc439c8546e5d3b0 and
e76e2c4ce76457e518b007b970e1b0c2742f8d6e)
-rw-r--r-- | sw/inc/fldbas.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/fields/fldbas.cxx | 15 | ||||
-rw-r--r-- | sw/source/core/layout/trvlfrm.cxx | 19 | ||||
-rw-r--r-- | sw/source/ui/wrtsh/wrtsh2.cxx | 2 |
4 files changed, 37 insertions, 1 deletions
diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx index 93c749599074..a3280f849930 100644 --- a/sw/inc/fldbas.hxx +++ b/sw/inc/fldbas.hxx @@ -352,6 +352,8 @@ public: void SetAutomaticLanguage(sal_Bool bSet){bIsAutomaticLanguage = bSet;} virtual String GetDescription() const; + /// Is this field clickable? + bool IsClickable() const; }; inline SwFieldType* SwField::GetTyp() const diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx index 2a693ea48810..93645332de30 100644 --- a/sw/source/core/fields/fldbas.cxx +++ b/sw/source/core/fields/fldbas.cxx @@ -764,6 +764,21 @@ String SwField::GetDescription() const return SW_RES(STR_FIELD); } +bool SwField::IsClickable() const +{ + switch (Which()) + { + case RES_JUMPEDITFLD: + case RES_MACROFLD: + case RES_GETREFFLD: + case RES_INPUTFLD: + case RES_SETEXPFLD: + case RES_DROPDOWN: + return true; + } + return false; +} + sal_uInt16 SwFldTypes::GetPos(const SwFieldType* pFieldType) const { const_iterator it = std::find(begin(), end(), pFieldType); diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx index ee907cd17468..0fa03e1f7792 100644 --- a/sw/source/core/layout/trvlfrm.cxx +++ b/sw/source/core/layout/trvlfrm.cxx @@ -61,6 +61,9 @@ #include <dcontact.hxx> // OD 2004-05-24 #i28701# #include <sortedobjs.hxx> +#include <txatbase.hxx> +#include <fmtfld.hxx> +#include <fldbas.hxx> // FLT_MAX #include <cfloat> @@ -301,10 +304,24 @@ sal_Bool SwPageFrm::GetCrsrOfst( SwPosition *pPos, Point &rPoint, bValidTextDistance = true; } + bool bConsiderBackground = true; + // If the text position is a clickable field, then that should have priority. + if (pTextNd->IsTxtNode()) + { + SwTxtNode* pTxtNd = pTextNd->GetTxtNode(); + SwTxtAttr* pTxtAttr = pTxtNd->GetTxtAttrForCharAt(aTextPos.nContent.GetIndex(), RES_TXTATR_FIELD); + if (pTxtAttr) + { + const SwField* pField = pTxtAttr->GetFld().GetFld(); + if (pField->IsClickable()) + bConsiderBackground = false; + } + } + double nBackDistance = 0; bool bValidBackDistance = false; SwCntntNode* pBackNd = aBackPos.nNode.GetNode( ).GetCntntNode( ); - if ( pBackNd ) + if ( pBackNd && bConsiderBackground) { // FIXME There are still cases were we don't have the proper node here. SwCntntFrm* pBackFrm = pBackNd->getLayoutFrm( getRootFrm( ) ); diff --git a/sw/source/ui/wrtsh/wrtsh2.cxx b/sw/source/ui/wrtsh/wrtsh2.cxx index 16196cc6b6e1..4d180b549d70 100644 --- a/sw/source/ui/wrtsh/wrtsh2.cxx +++ b/sw/source/ui/wrtsh/wrtsh2.cxx @@ -307,6 +307,8 @@ void SwWrtShell::ClickToField( const SwField& rFld ) case RES_DROPDOWN : StartDropDownFldDlg( (SwField*)&rFld, sal_False ); break; + default: + SAL_WARN_IF(rFld.IsClickable(), "sw", "unhandled clickable field!"); } bIsInClickToEdit = sal_False; |