sw/inc/PostItMgr.hxx | 6 +++--- sw/inc/unofield.hxx | 1 + sw/source/core/text/inftxt.cxx | 27 +++++++++++++++++++++++++-- sw/source/core/unocore/unofield.cxx | 22 ++++++++++++++++++++-- sw/source/core/unocore/unotext.cxx | 6 +++++- xmloff/inc/xmloff/odffields.hxx | 1 + 6 files changed, 55 insertions(+), 8 deletions(-)
New commits: commit 2c409f5a9871941ee380f200872769c62c665784 Author: Miklos Vajna <[email protected]> Date: Thu Jul 12 10:00:53 2012 +0200 SwTxtPaintInfo::_DrawBackBrush: color comment ranges Change-Id: I65f681d9fd5f0e7471da77608279c2dade38d7cb diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index 554ba0f..e3f0835 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -39,6 +39,7 @@ #include <editeng/splwrap.hxx> #include <editeng/pgrditem.hxx> #include <editeng/tstpitem.hxx> +#include <xmloff/odffields.hxx> #include <SwSmartTagMgr.hxx> #include <linguistic/lngprops.hxx> @@ -47,6 +48,9 @@ #include <editeng/forbiddenruleitem.hxx> #include <txatbase.hxx> #include <fmtinfmt.hxx> +#include <fmtfld.hxx> +#include <fldbas.hxx> +#include <PostItMgr.hxx> #include <swmodule.hxx> #include <vcl/svapp.hxx> #include <vcl/wrkwin.hxx> @@ -1081,7 +1085,7 @@ void SwTxtPaintInfo::_DrawBackBrush( const SwLinePortion &rPor ) const if(aIntersect.HasArea()) { SwTxtNode *pNd = pFrm->GetTxtNode(); - const ::sw::mark::IMark* pFieldmark = NULL; + const ::sw::mark::IFieldmark* pFieldmark = NULL; if(pNd) { const SwDoc *doc=pNd->GetDoc(); @@ -1107,7 +1111,26 @@ void SwTxtPaintInfo::_DrawBackBrush( const SwLinePortion &rPor ) const { OutputDevice* pOutDev = (OutputDevice*)GetOut(); pOutDev->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR ); - pOutDev->SetFillColor( SwViewOption::GetFieldShadingsColor() ); + bool bFilled = false; + // If this is a comment range, need to look up the color of the comment author. + if (pFieldmark->GetFieldname() == ODF_COMMENTRANGE) + { + // Search for the position of the postit field + const sal_Unicode fld[] = { CH_TXTATR_INWORD, 0 }; + xub_StrLen nEndIdx = GetTxt().SearchChar(fld, GetIdx()); + if (nEndIdx != STRING_NOTFOUND) + { + SwTxtAttr* pTxtAttr = pNd->GetTxtAttrForCharAt(nEndIdx, RES_TXTATR_FIELD); + const SwFmtFld& rPostItField = pTxtAttr->GetFld(); + // Look up the author name + const rtl::OUString& rAuthor = rPostItField.GetFld()->GetPar1(); + sal_uInt16 nIndex = pNd->GetDoc()->InsertRedlineAuthor(rAuthor); + pOutDev->SetFillColor( SwPostItMgr::GetColorLight(nIndex) ); + bFilled = true; + } + } + if (!bFilled) + pOutDev->SetFillColor( SwViewOption::GetFieldShadingsColor() ); pOutDev->SetLineColor( ); pOutDev->DrawRect( aIntersect.SVRect() ); pOutDev->Pop(); commit ec92841fd3ea9ddcaa99d5d352f61971ba9ea5ee Author: Miklos Vajna <[email protected]> Date: Thu Jul 12 10:00:32 2012 +0200 SwXTextField::attachToRange: use a fieldmark for annotation range insert Change-Id: I15d8be58924918cde827ee1d12308cf491cff35b diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index c30697b..ab20015 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -94,6 +94,7 @@ #include <switerator.hxx> #include <rtl/strbuf.hxx> #include <vector> +#include <xmloff/odffields.hxx> using ::rtl::OUString; using namespace ::com::sun::star; @@ -1741,7 +1742,7 @@ void SwXTextField::attachToRange( UnoActionContext aCont(pDoc); SwTxtAttr* pTxtAttr = 0; - if(aPam.HasMark()) + if(aPam.HasMark() && m_nServiceId != SW_SERVICE_FIELDTYPE_ANNOTATION) pDoc->DeleteAndJoin(aPam); SwXTextCursor const*const pTextCursor( @@ -1752,7 +1753,19 @@ void SwXTextField::attachToRange( ? nsSetAttrMode::SETATTR_FORCEHINTEXPAND : nsSetAttrMode::SETATTR_DEFAULT; - pDoc->InsertPoolItem(aPam, aFmt, nInsertFlags); + if (*aPam.GetPoint() != *aPam.GetMark() && m_nServiceId == SW_SERVICE_FIELDTYPE_ANNOTATION) + { + IDocumentMarkAccess* pMarksAccess = pDoc->getIDocumentMarkAccess(); + pMarksAccess->makeFieldBookmark( + aPam, + OUString(), + ODF_COMMENTRANGE); + + SwPaM aEnd(*aPam.GetMark(), *aPam.GetMark()); + pDoc->InsertPoolItem(aEnd, aFmt, nInsertFlags); + } + else + pDoc->InsertPoolItem(aPam, aFmt, nInsertFlags); pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_FIELD); commit ff3dc1d67002be4fa7a73785843087d0bc5ed123 Author: Miklos Vajna <[email protected]> Date: Thu Jul 12 09:59:43 2012 +0200 SwXText::insertTextContent: allow attaching an annotation field to a range Change-Id: I44633089c40a5a02655d4abb08fedd1acb014d15 diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index f9cd4a0..4a8f1ef 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -605,9 +605,13 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) ::sw::UnoTunnelGetImplementation<SwXReferenceMark>(xContentTunnel); SwXMeta *const pMeta = ::sw::UnoTunnelGetImplementation<SwXMeta>(xContentTunnel); + SwXTextField* pTextField = + ::sw::UnoTunnelGetImplementation<SwXTextField>(xContentTunnel); + if (pTextField && pTextField->GetServiceId() != SW_SERVICE_FIELDTYPE_ANNOTATION) + pTextField = 0; const bool bAttribute = pBookmark || pDocumentIndexMark - || pSection || pReferenceMark || pMeta; + || pSection || pReferenceMark || pMeta || pTextField; if (bAbsorb && !bAttribute) { commit fa72acc4bf926b5df3e484d72fcc9880994f7ea2 Author: Miklos Vajna <[email protected]> Date: Thu Jul 12 09:56:53 2012 +0200 SwXTextField: add getter method for m_nServiceId Change-Id: I5a4f65da17062db1334bb0140b7b4545494adfa6 diff --git a/sw/inc/unofield.hxx b/sw/inc/unofield.hxx index 71915fa..c583353 100644 --- a/sw/inc/unofield.hxx +++ b/sw/inc/unofield.hxx @@ -196,6 +196,7 @@ public: /// @return an SwXTextField, either an already existing one or a new one static SwXTextField* CreateSwXTextField(SwDoc & rDoc, SwFmtFld const& rFmt); + sal_uInt16 GetServiceId(); }; typedef diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index b2447f4..c30697b 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -1019,6 +1019,11 @@ SwXTextField* SwXTextField::CreateSwXTextField(SwDoc & rDoc, SwFmtFld const& rFm return pField ? pField : new SwXTextField( rFmt, &rDoc ); } +sal_uInt16 SwXTextField::GetServiceId() +{ + return m_nServiceId; +} + struct SwFieldProperties_Impl { String sPar1; commit f98fbc38640816aa1f834f0e932991ae0d3202ee Author: Miklos Vajna <[email protected]> Date: Thu Jul 12 09:53:36 2012 +0200 SwPostItMgr: these can be static Change-Id: I83b18d86c61e38ebe344d0b4153513ad65b20720 diff --git a/sw/inc/PostItMgr.hxx b/sw/inc/PostItMgr.hxx index 502f750..8540697 100644 --- a/sw/inc/PostItMgr.hxx +++ b/sw/inc/PostItMgr.hxx @@ -262,9 +262,9 @@ class SwPostItMgr: public SfxListener void SetSpellChecking(); - Color GetColorDark(sal_uInt16 aAuthorIndex); - Color GetColorLight(sal_uInt16 aAuthorIndex); - Color GetColorAnchor(sal_uInt16 aAuthorIndex); + static Color GetColorDark(sal_uInt16 aAuthorIndex); + static Color GetColorLight(sal_uInt16 aAuthorIndex); + static Color GetColorAnchor(sal_uInt16 aAuthorIndex); void RegisterAnswer(OutlinerParaObject* pAnswer) { mpAnswer = pAnswer;} commit 25416b8ad4fa0416bffdb05e231a5249faf7a38e Author: Miklos Vajna <[email protected]> Date: Thu Jul 12 09:53:17 2012 +0200 xmloff: add new constant for commentrange field type Change-Id: I9bdf184f5a8f414144d9dea814d6179ec2134209 diff --git a/xmloff/inc/xmloff/odffields.hxx b/xmloff/inc/xmloff/odffields.hxx index b144f13..a116350 100644 --- a/xmloff/inc/xmloff/odffields.hxx +++ b/xmloff/inc/xmloff/odffields.hxx @@ -46,6 +46,7 @@ #define ODF_OLE_PARAM "vnd.oasis.opendocument.field.ole" #define ODF_ID_PARAM "vnd.oasis.opendocument.field.id" #define ODF_CODE_PARAM "vnd.oasis.opendocument.field.code" +#define ODF_COMMENTRANGE "vnd.oasis.opendocument.field.COMMENTRANGE" #endif /* _ODFFIELDS_HXX */ _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
