summaryrefslogtreecommitdiff
path: root/sw/source/core
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core')
-rw-r--r--sw/source/core/crsr/bookmrk.cxx73
-rw-r--r--sw/source/core/crsr/crossrefbookmark.cxx2
-rw-r--r--sw/source/core/crsr/crstrvl.cxx11
-rw-r--r--sw/source/core/crsr/makefile.mk1
-rw-r--r--sw/source/core/crsr/pam.cxx40
-rw-r--r--sw/source/core/doc/docbm.cxx43
-rw-r--r--sw/source/core/edit/edtox.cxx22
-rw-r--r--sw/source/core/inc/MarkManager.hxx10
-rw-r--r--sw/source/core/inc/bookmrk.hxx60
-rw-r--r--sw/source/core/inc/crossrefbookmark.hxx6
-rw-r--r--sw/source/core/text/inftxt.cxx57
-rw-r--r--sw/source/core/text/portxt.cxx121
-rw-r--r--sw/source/core/unocore/unobkm.cxx137
13 files changed, 437 insertions, 146 deletions
diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index 6752f70e5eaf..11060352b6c3 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -41,12 +41,14 @@
#include <undobj.hxx>
#include <unobookmark.hxx>
#include <rtl/random.h>
+#include <xmloff/odffields.hxx>
SV_IMPL_REF( SwServerObject )
using namespace ::sw::mark;
using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
namespace
{
@@ -75,20 +77,20 @@ namespace
const sal_Unicode aStartMark,
const sal_Unicode aEndMark)
{
- const SwPosition& rStart = pField->GetMarkStart();
- const SwPosition& rEnd = pField->GetMarkEnd();
+ SwPosition& rStart = pField->GetMarkStart();
+ SwPosition& rEnd = pField->GetMarkEnd();
SwTxtNode const * const pStartTxtNode = io_pDoc->GetNodes()[rStart.nNode]->GetTxtNode();
SwTxtNode const * const pEndTxtNode = io_pDoc->GetNodes()[rEnd.nNode]->GetTxtNode();
const sal_Unicode ch_start=pStartTxtNode->GetTxt().GetChar(rStart.nContent.GetIndex());
const sal_Unicode ch_end=pEndTxtNode->GetTxt().GetChar(rEnd.nContent.GetIndex()-1);
- const SwPaM aStartPaM(rStart);
- const SwPaM aEndPaM(rEnd);
+ SwPaM aStartPaM(rStart);
+ SwPaM aEndPaM(rEnd);
io_pDoc->StartUndo(UNDO_UI_REPLACE, NULL);
if(ch_start != aStartMark)
{
io_pDoc->InsertString(aStartPaM, aStartMark);
}
- if(aEndMark && ch_end != aEndMark)
+ if ( aEndMark && ( ch_end != aEndMark ) && ( rStart != rEnd ) )
{
io_pDoc->InsertString(aEndPaM, aEndMark);
}
@@ -112,6 +114,11 @@ namespace sw { namespace mark
}
}
+ bool MarkBase::IsCoveringPosition(const SwPosition& rPos) const
+ {
+ return GetMarkStart() <= rPos && rPos <= GetMarkEnd();
+ }
+
void MarkBase::SetMarkPos(const SwPosition& rNewPos)
{
::boost::scoped_ptr<SwPosition>(new SwPosition(rNewPos)).swap(m_pPos1);
@@ -124,6 +131,17 @@ namespace sw { namespace mark
//lcl_FixPosition(*m_pPos2);
}
+ rtl::OUString MarkBase::ToString( ) const
+ {
+ rtl::OUStringBuffer buf;
+ buf.appendAscii( "Mark: ( Name, [ Node1, Index1 ] ): ( " );
+ buf.append( m_aName ).appendAscii( ", [ " );
+ buf.append( sal_Int32( GetMarkPos().nNode.GetIndex( ) ) ).appendAscii( ", " );
+ buf.append( sal_Int32( GetMarkPos().nContent.GetIndex( ) ) ).appendAscii( " ] )" );
+
+ return buf.makeStringAndClear( );
+ }
+
MarkBase::~MarkBase()
{ }
@@ -145,7 +163,7 @@ namespace sw { namespace mark
return aResult.append(nCount++).append(sUniquePostfix).makeStringAndClear();
}
- // SwClient
+
void MarkBase::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew)
{
SwModify::Modify(pOld, pNew);
@@ -250,6 +268,7 @@ namespace sw { namespace mark
uno::Reference< rdf::XMetadatable > Bookmark::MakeUnoObject()
{
+ // create new SwXBookmark
SwDoc *const pDoc( GetMarkPos().GetDoc() );
OSL_ENSURE(pDoc, "Bookmark::MakeUnoObject: no doc?");
const uno::Reference< rdf::XMetadatable> xMeta(
@@ -265,6 +284,28 @@ namespace sw { namespace mark
SetOtherMarkPos(GetMarkPos());
}
+ rtl::OUString Fieldmark::ToString( ) const
+ {
+ rtl::OUStringBuffer buf;
+ buf.appendAscii( "Fieldmark: ( Name, Type, [ Nd1, Id1 ], [ Nd2, Id2 ] ): ( " );
+ buf.append( m_aName ).appendAscii( ", " );
+ buf.append( m_aFieldname ).appendAscii( ", [ " );
+ buf.append( sal_Int32( GetMarkPos().nNode.GetIndex( ) ) ).appendAscii( ", " );
+ buf.append( sal_Int32( GetMarkPos( ).nContent.GetIndex( ) ) ).appendAscii( " ], [" );
+ buf.append( sal_Int32( GetOtherMarkPos().nNode.GetIndex( ) ) ).appendAscii( ", " );
+ buf.append( sal_Int32( GetOtherMarkPos( ).nContent.GetIndex( ) ) ).appendAscii( " ] ) " );
+
+ return buf.makeStringAndClear( );
+ }
+
+ void Fieldmark::Invalidate( )
+ {
+ // @TODO: Does exist a better solution to trigger a format of the
+ // fieldmark portion? If yes, please use it.
+ SwPaM aPaM( this->GetMarkPos(), this->GetOtherMarkPos() );
+ aPaM.InvalidatePaM();
+ }
+
const ::rtl::OUString Fieldmark::our_sNamePrefix = ::rtl::OUString::createFromAscii("__Fieldmark__");
TextFieldmark::TextFieldmark(const SwPaM& rPaM)
@@ -282,12 +323,24 @@ namespace sw { namespace mark
void CheckboxFieldmark::InitDoc(SwDoc* const io_pDoc)
{
- lcl_AssureFieldMarksSet(this, io_pDoc, CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FIELDEND);
- }
+ lcl_AssureFieldMarksSet(this, io_pDoc, CH_TXT_ATR_FORMELEMENT, CH_TXT_ATR_FIELDEND);
+ // For some reason the end mark is moved from 1 by the Insert: we don't
+ // want this for checkboxes
+ this->GetMarkEnd( ).nContent--;
+ }
void CheckboxFieldmark::SetChecked(bool checked)
- { m_isChecked = checked; }
+ {
+ (*GetParameters())[::rtl::OUString::createFromAscii(ODF_FORMCHECKBOX_RESULT)] = makeAny(checked);
+ }
bool CheckboxFieldmark::IsChecked() const
- { return m_isChecked; }
+ {
+ bool bResult = false;
+ parameter_map_t::const_iterator pResult = GetParameters()->find(::rtl::OUString::createFromAscii(ODF_FORMCHECKBOX_RESULT));
+ if(pResult != GetParameters()->end())
+ pResult->second >>= bResult;
+ return bResult;
+ }
+
}}
diff --git a/sw/source/core/crsr/crossrefbookmark.cxx b/sw/source/core/crsr/crossrefbookmark.cxx
index 4e0d1a4151e9..dc083801ee8e 100644
--- a/sw/source/core/crsr/crossrefbookmark.cxx
+++ b/sw/source/core/crsr/crossrefbookmark.cxx
@@ -64,7 +64,7 @@ namespace sw { namespace mark
MarkBase::SetMarkPos(rNewPos);
}
- const SwPosition& CrossRefBookmark::GetOtherMarkPos() const
+ SwPosition& CrossRefBookmark::GetOtherMarkPos() const
{
OSL_PRECOND(false,
"<SwCrossRefBookmark::GetOtherMarkPos(..)>"
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index 56986a9cf5e7..818ccc6e228f 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -1172,6 +1172,17 @@ BOOL SwCrsrShell::GetContentAtPos( const Point& rPt,
}
}
+ if( !bRet && SwContentAtPos::SW_FORMCTRL & rCntntAtPos.eCntntAtPos )
+ {
+ IDocumentMarkAccess* pMarksAccess = GetDoc()->getIDocumentMarkAccess( );
+ sw::mark::IFieldmark* pFldBookmark = pMarksAccess->getFieldmarkFor( aPos );
+ if( bCrsrFoundExact && pTxtNd && pFldBookmark) {
+ rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_FORMCTRL;
+ rCntntAtPos.aFnd.pFldmark = pFldBookmark;
+ bRet=TRUE;
+ }
+ }
+
if( !bRet && SwContentAtPos::SW_FTN & rCntntAtPos.eCntntAtPos )
{
if( aTmpState.bFtnNoInfo )
diff --git a/sw/source/core/crsr/makefile.mk b/sw/source/core/crsr/makefile.mk
index 6d579171dc02..a2571901c068 100644
--- a/sw/source/core/crsr/makefile.mk
+++ b/sw/source/core/crsr/makefile.mk
@@ -47,6 +47,7 @@ CDEFS+=-Dmydebug
EXCEPTIONSFILES= \
$(SLO)$/crbm.obj \
$(SLO)$/crsrsh.obj \
+ $(SLO)$/bookmrk.obj \
$(SLO)$/viscrs.obj
SLOFILES = \
diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx
index 565669bd7a35..ec30b5aefbe0 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -53,6 +53,7 @@
#include <ndtxt.hxx> // #111827#
#include <IMark.hxx>
+#include <hints.hxx>
// fuer den dummen ?MSC-? Compiler
inline xub_StrLen GetSttOrEnd( BOOL bCondition, const SwCntntNode& rNd )
@@ -824,16 +825,21 @@ BOOL SwPaM::HasReadonlySel( bool bFormView ) const
}
//FIXME FieldBk
// TODO: Form Protection when Enhanced Fields are enabled
-// if( !bRet )
-// {
-// const SwDoc *pDoc=GetDoc();
-// SwBookmark *pA = ( pDoc && pPoint ? pDoc->getFieldmarkFor( *pPoint ) : NULL );
-// SwBookmark *pB = ( pDoc && pMark ? pDoc->getFieldmarkFor( *pMark ) : pA );
-// bRet = ( pA != pB );
-// bool bProtectForm = pDoc->get( IDocumentSettingAccess::PROTECT_FORM );
-// if( bProtectForm )
-// bRet |= ( pA==NULL || pB==NULL );
-// }
+ if (!bRet) {
+ const SwDoc *pDoc = GetDoc();
+ sw::mark::IMark* pA = NULL;
+ sw::mark::IMark* pB = NULL;
+ if ( pDoc )
+ {
+ const IDocumentMarkAccess* pMarksAccess = pDoc->getIDocumentMarkAccess( );
+ pA = GetPoint() ? pMarksAccess->getFieldmarkFor( *GetPoint( ) ) : NULL;
+ pB = GetMark( ) ? pMarksAccess->getFieldmarkFor( *GetMark( ) ) : pA;
+ bRet = ( pA != pB );
+ }
+ bool bProtectForm = pDoc->get( IDocumentSettingAccess::PROTECT_FORM );
+ if ( bProtectForm )
+ bRet |= ( pA == NULL || pB == NULL );
+ }
return bRet;
}
@@ -1220,6 +1226,20 @@ BOOL SwPaM::Overlap(const SwPaM & a, const SwPaM & b)
return !(*b.End() <= *a.Start() || *a.End() <= *b.End());
}
+void SwPaM::InvalidatePaM()
+{
+ const SwNode *_pNd=this->GetNode();
+ const SwTxtNode *_pTxtNd=(_pNd!=NULL?_pNd->GetTxtNode():NULL);
+ if (_pTxtNd!=NULL)
+ {
+ // pretent that the PaM marks inserted text to recalc the portion...
+ SwInsTxt aHint( Start()->nContent.GetIndex(),
+ End()->nContent.GetIndex() - Start()->nContent.GetIndex() + 1 );
+ SwModify *_pModify=(SwModify*)_pTxtNd;
+ _pModify->Modify( 0, &aHint);
+ }
+}
+
BOOL SwPaM::LessThan(const SwPaM & a, const SwPaM & b)
{
return (*a.Start() < *b.Start()) || (*a.Start() == *b.Start() && *a.End() < *b.End());
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 12edc1858b87..1e058867ba32 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -37,6 +37,7 @@
#include <dcontact.hxx>
#include <doc.hxx>
#include <docary.hxx>
+#include <xmloff/odffields.hxx>
#include <editsh.hxx>
#include <errhdl.hxx>
#include <fmtanchr.hxx>
@@ -305,6 +306,17 @@ namespace sw { namespace mark
: m_pDoc(&rDoc)
{ }
+ void MarkManager::dumpFieldmarks( ) const
+ {
+ const_iterator_t pIt = m_vFieldmarks.begin();
+ for (; pIt != m_vFieldmarks.end( ); pIt++)
+ {
+ rtl::OUString str = (*pIt)->ToString();
+ OSL_TRACE("%s\n",
+ ::rtl::OUStringToOString(str, RTL_TEXTENCODING_UTF8).getStr());
+ }
+ }
+
::sw::mark::IMark* MarkManager::makeMark(const SwPaM& rPaM,
const ::rtl::OUString& rName,
const IDocumentMarkAccess::MarkType eType)
@@ -410,6 +422,30 @@ namespace sw { namespace mark
return pMark.get();
}
+ ::sw::mark::IFieldmark* MarkManager::makeFieldBookmark( const SwPaM& rPaM,
+ const rtl::OUString& rName,
+ const rtl::OUString& rType )
+ {
+ sw::mark::IMark* pMark = makeMark( rPaM, rName,
+ IDocumentMarkAccess::TEXT_FIELDMARK );
+ sw::mark::IFieldmark* pFieldMark = dynamic_cast<sw::mark::IFieldmark*>( pMark );
+ pFieldMark->SetFieldname( rType );
+
+ return pFieldMark;
+ }
+
+ ::sw::mark::IFieldmark* MarkManager::makeNoTextFieldBookmark( const SwPaM& rPaM,
+ const rtl::OUString& rName,
+ const rtl::OUString& rType)
+ {
+ sw::mark::IMark* pMark = makeMark( rPaM, rName,
+ IDocumentMarkAccess::CHECKBOX_FIELDMARK );
+ sw::mark::IFieldmark* pFieldMark = dynamic_cast<sw::mark::IFieldmark*>( pMark );
+ pFieldMark->SetFieldname( rType );
+
+ return pFieldMark;
+ }
+
::sw::mark::IMark* MarkManager::getMarkForTxtNode(const SwTxtNode& rTxtNode,
const IDocumentMarkAccess::MarkType eType)
{
@@ -763,12 +799,7 @@ namespace sw { namespace mark
{
const_iterator_t pFieldmark = find_if(
m_vFieldmarks.begin(),
- // we do not need to check marks starting behind the positon
- lower_bound(
- m_vFieldmarks.begin(),
- m_vFieldmarks.end(),
- rPos,
- bind(&IMark::StartsAfter, _1, _2)),
+ m_vFieldmarks.end( ),
bind(&IMark::IsCoveringPosition, _1, rPos));
if(pFieldmark == m_vFieldmarks.end()) return NULL;
return dynamic_cast<IFieldmark*>(pFieldmark->get());
diff --git a/sw/source/core/edit/edtox.cxx b/sw/source/core/edit/edtox.cxx
index 97b2531cdbe2..d6fb64577e11 100644
--- a/sw/source/core/edit/edtox.cxx
+++ b/sw/source/core/edit/edtox.cxx
@@ -57,6 +57,9 @@
#ifndef _STATSTR_HRC
#include <statstr.hrc>
#endif
+#include <bookmrk.hxx>
+#include <xmloff/odffields.hxx>
+
using namespace ::com::sun::star;
using namespace ::com::sun::star::i18n;
@@ -232,6 +235,25 @@ BOOL SwEditShell::UpdateTableOf( const SwTOXBase& rTOX, const SfxItemSet* pSet )
return bRet;
}
+BOOL SwEditShell::UpdateField( sw::mark::IFieldmark &fieldBM)
+{
+// SwDocShell* pDocSh = pDoc->GetDocShell();
+ //@TODO implement me...; add undo etc...
+ if ( pDoc && fieldBM.IsExpanded( ) ) {
+ SwPosition aSttPos = fieldBM.GetMarkStart( );
+ aSttPos.nContent++;
+
+ SwPosition aEndPos = fieldBM.GetMarkEnd( );
+ aEndPos.nContent--;
+
+ SwPaM aPaM( aSttPos, aEndPos );
+ pDoc->DeleteRange(aPaM);
+ pDoc->InsertString(aPaM, String::CreateFromAscii("Implement me ;-)") );
+ }
+ return TRUE;
+}
+
+
/*--------------------------------------------------------------------
Beschreibung: Aktuelles Verzeichnis vor oder in dem der Cursor
steht
diff --git a/sw/source/core/inc/MarkManager.hxx b/sw/source/core/inc/MarkManager.hxx
index faaa487d7467..1a5cd1724050 100644
--- a/sw/source/core/inc/MarkManager.hxx
+++ b/sw/source/core/inc/MarkManager.hxx
@@ -40,8 +40,18 @@ namespace sw { namespace mark
public:
MarkManager(/*[in/out]*/ SwDoc& rDoc);
+ void dumpFieldmarks( ) const;
+
// IDocumentMarkAccess
virtual ::sw::mark::IMark* makeMark(const SwPaM& rPaM, const ::rtl::OUString& rName, IDocumentMarkAccess::MarkType eMark);
+
+ virtual sw::mark::IFieldmark* makeFieldBookmark( const SwPaM& rPaM,
+ const rtl::OUString& rName,
+ const rtl::OUString& rType);
+ virtual sw::mark::IFieldmark* makeNoTextFieldBookmark( const SwPaM& rPaM,
+ const rtl::OUString& rName,
+ const rtl::OUString& rType);
+
virtual ::sw::mark::IMark* getMarkForTxtNode(const SwTxtNode& rTxtNode, IDocumentMarkAccess::MarkType eMark);
virtual void repositionMark(::sw::mark::IMark* io_pMark, const SwPaM& rPaM);
diff --git a/sw/source/core/inc/bookmrk.hxx b/sw/source/core/inc/bookmrk.hxx
index 1b341a57ae2e..90c6a44fa239 100644
--- a/sw/source/core/inc/bookmrk.hxx
+++ b/sw/source/core/inc/bookmrk.hxx
@@ -34,6 +34,7 @@
#include <boost/scoped_ptr.hpp>
#include <boost/noncopyable.hpp>
+#include <map>
#include <IMark.hxx>
@@ -53,26 +54,31 @@ namespace sw { namespace mark
{
public:
//getters
- virtual const SwPosition& GetMarkPos() const
+ virtual SwPosition& GetMarkPos() const
{ return *m_pPos1; }
virtual const ::rtl::OUString& GetName() const
{ return m_aName; }
- virtual bool IsCoveringPosition(const SwPosition& rPos) const
- { return GetMarkStart() <= rPos && rPos <= GetMarkEnd(); };
- virtual const SwPosition& GetOtherMarkPos() const
+ virtual bool IsCoveringPosition(const SwPosition& rPos) const;
+ virtual SwPosition& GetOtherMarkPos() const
{
OSL_PRECOND(IsExpanded(), "<SwPosition::GetOtherMarkPos(..)> - I have no other Pos set." );
return *m_pPos2;
}
- virtual const SwPosition& GetMarkStart() const
+ virtual SwPosition& GetMarkStart() const
{
- if(!m_pPos2 /* !IsExpanded()*/) return *m_pPos1;
- return *m_pPos1 < *m_pPos2 ? *m_pPos1 : *m_pPos2;
+ if( !IsExpanded() ) return GetMarkPos( );
+ if ( GetMarkPos( ) < GetOtherMarkPos( ) )
+ return GetMarkPos();
+ else
+ return GetOtherMarkPos( );
}
- virtual const SwPosition& GetMarkEnd() const
+ virtual SwPosition& GetMarkEnd() const
{
- if(!m_pPos2 /* !IsExpanded()*/ ) return *m_pPos1;
- return *m_pPos1 > *m_pPos2 ? *m_pPos1 : *m_pPos2;
+ if( !IsExpanded() ) return GetMarkPos();
+ if ( GetMarkPos( ) > GetOtherMarkPos( ) )
+ return GetMarkPos( );
+ else
+ return GetOtherMarkPos( );
}
virtual bool IsExpanded() const
{ return m_pPos2; }
@@ -85,6 +91,8 @@ namespace sw { namespace mark
virtual void ClearOtherMarkPos()
{ m_pPos2.reset(); }
+ virtual rtl::OUString ToString( ) const;
+
virtual void Swap()
{
if(m_pPos2)
@@ -120,7 +128,6 @@ namespace sw { namespace mark
class NavigatorReminder
: public MarkBase
- , virtual public IMark
{
public:
NavigatorReminder(const SwPaM& rPaM);
@@ -204,24 +211,31 @@ namespace sw { namespace mark
Fieldmark(const SwPaM& rPaM);
// getters
- ::rtl::OUString GetFieldname() const
+ virtual ::rtl::OUString GetFieldname() const
{ return m_aFieldname; }
- ::rtl::OUString GetFieldHelptext() const
+ virtual ::rtl::OUString GetFieldHelptext() const
{ return m_aFieldHelptext; }
+ virtual IFieldmark::parameter_map_t* GetParameters()
+ { return &m_vParams; }
+
+ virtual const IFieldmark::parameter_map_t* GetParameters() const
+ { return &m_vParams; }
+
// setters
- void SetFieldname(const ::rtl::OUString& aFieldname)
+ virtual void SetFieldname(const ::rtl::OUString& aFieldname)
{ m_aFieldname = aFieldname; }
- void SetFieldHelptext(const ::rtl::OUString& aFieldHelptext)
+ virtual void SetFieldHelptext(const ::rtl::OUString& aFieldHelptext)
{ m_aFieldHelptext = aFieldHelptext; }
- private:
- //int fftype; // Type: 0 = Text, 1 = Check Box, 2 = List
- //bool ffprot;
+ virtual void Invalidate();
+ virtual rtl::OUString ToString() const;
+ private:
::rtl::OUString m_aFieldname;
::rtl::OUString m_aFieldHelptext;
- static const ::rtl::OUString our_sNamePrefix;
+ IFieldmark::parameter_map_t m_vParams;
+ static const ::rtl::OUString our_sNamePrefix;
};
class TextFieldmark
@@ -230,9 +244,6 @@ namespace sw { namespace mark
public:
TextFieldmark(const SwPaM& rPaM);
virtual void InitDoc(SwDoc* const io_pDoc);
- private:
- //int fftypetxt; // Type of text field: 0 = Regular text, 1 = Number, 2 = Date, 3 = Current date, 4 = Current time, 5 = Calculation
- //int ffmaxlen; // Number of characters for text field. Zero means unlimited.
};
class CheckboxFieldmark
@@ -244,11 +255,6 @@ namespace sw { namespace mark
virtual void InitDoc(SwDoc* const io_pDoc);
bool IsChecked() const;
void SetChecked(bool checked);
- private:
- bool m_isChecked;
- //bool ffsize; // 0 = Auto, 1=Exact (see ffhps)
- //bool ffrecalc;
- //int ffhps; // Check box size (half-point sizes).
};
}}
diff --git a/sw/source/core/inc/crossrefbookmark.hxx b/sw/source/core/inc/crossrefbookmark.hxx
index cfacf26c65d5..27f920be7651 100644
--- a/sw/source/core/inc/crossrefbookmark.hxx
+++ b/sw/source/core/inc/crossrefbookmark.hxx
@@ -45,10 +45,10 @@ namespace sw { namespace mark
const ::rtl::OUString& rPrefix);
// getters
- virtual const SwPosition& GetOtherMarkPos() const;
- virtual const SwPosition& GetMarkStart() const
+ virtual SwPosition& GetOtherMarkPos() const;
+ virtual SwPosition& GetMarkStart() const
{ return *m_pPos1; }
- virtual const SwPosition& GetMarkEnd() const
+ virtual SwPosition& GetMarkEnd() const
{ return *m_pPos1; }
virtual bool IsExpanded() const
{ return false; }
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index 9341206dfa71..f7c96d9dc745 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -1142,27 +1142,30 @@ void SwTxtPaintInfo::DrawCheckBox( const SwFieldFormPortion &rPor, bool checked)
{
SwRect aIntersect;
CalcRect( rPor, &aIntersect, 0 );
- if ( aIntersect.HasArea() ) {
- if (OnWin()) {
- OutputDevice* pOutDev = (OutputDevice*)GetOut();
- pOutDev->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
- pOutDev->SetLineColor( Color(220, 233, 245));
- pOutDev->SetFillColor( Color(220, 233, 245));
- pOutDev->DrawRect( aIntersect.SVRect() );
- pOutDev->Pop();
- }
- const int delta=10;
- Rectangle r(aIntersect.Left()+delta, aIntersect.Top()+delta, aIntersect.Right()-delta, aIntersect.Bottom()-delta);
- pOut->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
- pOut->SetLineColor( Color(0, 0, 0));
- pOut->SetFillColor();
- pOut->DrawRect( r );
- if (checked) {
- pOut->DrawLine(r.TopLeft(), r.BottomRight());
- pOut->DrawLine(r.TopRight(), r.BottomLeft());
+ if ( aIntersect.HasArea() )
+ {
+ if (OnWin() && SwViewOption::IsFieldShadings() &&
+ !GetOpt().IsPagePreview())
+ {
+ OutputDevice* pOut_ = (OutputDevice*)GetOut();
+ pOut_->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
+ pOut_->SetFillColor( SwViewOption::GetFieldShadingsColor() );
+ pOut_->SetLineColor();
+ pOut_->DrawRect( aIntersect.SVRect() );
+ pOut_->Pop();
+ }
+ const int delta=10;
+ Rectangle r(aIntersect.Left()+delta, aIntersect.Top()+delta, aIntersect.Right()-delta, aIntersect.Bottom()-delta);
+ pOut->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
+ pOut->SetLineColor( Color(0, 0, 0));
+ pOut->SetFillColor();
+ pOut->DrawRect( r );
+ if (checked) {
+ pOut->DrawLine(r.TopLeft(), r.BottomRight());
+ pOut->DrawLine(r.TopRight(), r.BottomLeft());
+ }
pOut->Pop();
}
- }
}
/*************************************************************************
@@ -1216,14 +1219,22 @@ void SwTxtPaintInfo::_DrawBackBrush( const SwLinePortion &rPor ) const
}
}
bool bIsStartMark=(1==GetLen() && CH_TXT_ATR_FIELDSTART==GetTxt().GetChar(GetIdx()));
- if(pFieldmark) OSL_TRACE("Found Fieldmark");
+ if(pFieldmark) {
+ OSL_TRACE("Found Fieldmark");
+#if DEBUG
+ rtl::OUString str = pFieldmark->ToString( );
+ fprintf( stderr, "%s\n", rtl::OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr( ) );
+#endif
+ }
if(bIsStartMark) OSL_TRACE("Found StartMark");
- if (OnWin() && (pFieldmark!=NULL || bIsStartMark))
+ if (OnWin() && (pFieldmark!=NULL || bIsStartMark) &&
+ SwViewOption::IsFieldShadings() &&
+ !GetOpt().IsPagePreview())
{
OutputDevice* pOutDev = (OutputDevice*)GetOut();
pOutDev->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
- pOutDev->SetLineColor( Color(220, 233, 245));
- pOutDev->SetFillColor( Color(220, 233, 245));
+ pOutDev->SetFillColor( SwViewOption::GetFieldShadingsColor() );
+ pOutDev->SetLineColor( );
pOutDev->DrawRect( aIntersect.SVRect() );
pOutDev->Pop();
}
diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx
index 3eedc0c8c983..b1d236cb0471 100644
--- a/sw/source/core/text/portxt.cxx
+++ b/sw/source/core/text/portxt.cxx
@@ -52,11 +52,13 @@
#include <IMark.hxx>
#include <pam.hxx>
#include <doc.hxx>
+#include <xmloff/odffields.hxx>
#if OSL_DEBUG_LEVEL > 1
const sal_Char *GetLangName( const MSHORT nLang );
#endif
+using namespace ::sw::mark;
using namespace ::com::sun::star;
using namespace ::com::sun::star::i18n::ScriptType;
@@ -349,7 +351,7 @@ sal_Bool SwTxtPortion::_Format( SwTxtFormatInfo &rInf )
// C2 break iterator does not found a possible line break at all:
// ==> line break
- // case A: line not yet full
+ // case A: line not yet full
if ( !bFull )
{
Width( aGuess.BreakWidth() );
@@ -655,7 +657,7 @@ xub_StrLen SwTxtPortion::GetSpaceCnt( const SwTxtSizeInfo &rInf,
long SwTxtPortion::CalcSpacing( long nSpaceAdd, const SwTxtSizeInfo &rInf ) const
{
- xub_StrLen nCnt = 0;
+ xub_StrLen nCnt = 0;
if ( InExpGrp() )
{
@@ -766,9 +768,10 @@ void SwHolePortion::HandlePortion( SwPortionHandler& rPH ) const
rPH.Text( GetLen(), GetWhichPor() );
}
-void SwFieldMarkPortion::Paint( const SwTxtPaintInfo & rInf) const
+void SwFieldMarkPortion::Paint( const SwTxtPaintInfo & /*rInf*/) const
{
- SwTxtPortion::Paint(rInf);
+ // These shouldn't be painted!
+ // SwTxtPortion::Paint(rInf);
}
sal_Bool SwFieldMarkPortion::Format( SwTxtFormatInfo & )
@@ -778,38 +781,96 @@ sal_Bool SwFieldMarkPortion::Format( SwTxtFormatInfo & )
return ret;
}
+namespace {
+ static sal_Int32 getCurrentListIndex( IFieldmark* pBM,
+ ::rtl::OUString* io_pCurrentText = NULL )
+ {
+ const IFieldmark::parameter_map_t* const pParameters = pBM->GetParameters();
+ sal_Int32 nCurrentIdx = 0;
+ const IFieldmark::parameter_map_t::const_iterator pResult = pParameters->find(::rtl::OUString::createFromAscii(ODF_FORMDROPDOWN_RESULT));
+ if(pResult != pParameters->end())
+ pResult->second >>= nCurrentIdx;
+ if(io_pCurrentText)
+ {
+ const IFieldmark::parameter_map_t::const_iterator pListEntries = pParameters->find(::rtl::OUString::createFromAscii(ODF_FORMDROPDOWN_LISTENTRY));
+ if(pListEntries != pParameters->end())
+ {
+ uno::Sequence< ::rtl::OUString > vListEntries;
+ pListEntries->second >>= vListEntries;
+ if(nCurrentIdx < vListEntries.getLength())
+ *io_pCurrentText = vListEntries[nCurrentIdx];
+ }
+ }
+ return nCurrentIdx;
+ }
+}
//FIXME Fieldbk
-//void SwFieldFormPortion::Paint( const SwTxtPaintInfo& rInf ) const
-void SwFieldFormPortion::Paint( const SwTxtPaintInfo& ) const
+void SwFieldFormPortion::Paint( const SwTxtPaintInfo& rInf ) const
{
-// SwTxtNode *pNd=const_cast<SwTxtNode*>(rInf.GetTxtFrm()->GetTxtNode());
-// const SwDoc *doc=pNd->GetDoc();
-// SwIndex aIndex( pNd, rInf.GetIdx() );
-// SwPosition aPosition(*pNd, aIndex);
-// pMark = dynamic_cast< doc->getFieldmarkFor(aPosition);
-// OSL_ENSURE(pMark,
-// "SwFieldFormPortion::Paint(..)"
-// " - Where is my form field bookmark???");
-
-// bool checked=(pBM!=NULL?pBM->IsChecked():false);
-// rInf.DrawCheckBox(*this , checked);
-}
+ SwTxtNode* pNd = const_cast<SwTxtNode*>(rInf.GetTxtFrm()->GetTxtNode());
+ const SwDoc *doc=pNd->GetDoc();
+ SwIndex aIndex( pNd, rInf.GetIdx() );
+ SwPosition aPosition(*pNd, aIndex);
-sal_Bool SwFieldFormPortion::Format( SwTxtFormatInfo &rInf )
-{
- sal_Bool ret=0;
-// ret=SwTxtPortion::Format(rInf);
+ IFieldmark* pBM = doc->getIDocumentMarkAccess( )->getFieldmarkFor( aPosition );
+
+ OSL_ENSURE( pBM,
+ "SwFieldFormPortion::Paint(..)"
+ " - Where is my form field bookmark???");
- Width(rInf.GetTxtHeight());
- Height(rInf.GetTxtHeight());
- SetAscent(rInf.GetAscent());
- //int h=rInf.GetTxtHeight();
+ if ( pBM != NULL )
+ {
+ if ( pBM->GetFieldname( ).equalsAscii( ODF_FORMCHECKBOX ) )
+ { // a checkbox...
+ ICheckboxFieldmark* pCheckboxFm = dynamic_cast< ICheckboxFieldmark* >(pBM);
+ bool checked = pCheckboxFm->IsChecked();
+ rInf.DrawCheckBox(*this, checked);
+ }
+ else if ( pBM->GetFieldname( ).equalsAscii( ODF_FORMDROPDOWN ) )
+ { // a list...
+ rtl::OUString aTxt;
+ rInf.DrawViewOpt( *this, POR_FLD );
+ rInf.DrawText( aTxt, *this, 0, 0/*aTxt.getLength()*/, false );
+ }
+ else
+ {
+ assert(0); // unknown type...
+ }
+ }
+}
-/*
- Height(100);
- SetAscent(100);
-*/
+sal_Bool SwFieldFormPortion::Format( SwTxtFormatInfo & rInf )
+{
+ sal_Bool ret = 0;
+ SwTxtNode *pNd = const_cast < SwTxtNode * >( rInf.GetTxtFrm( )->GetTxtNode( ) );
+ const SwDoc *doc = pNd->GetDoc( );
+ SwIndex aIndex( pNd, rInf.GetIdx( ) );
+ SwPosition aPosition( *pNd, aIndex );
+ IFieldmark *pBM = doc->getIDocumentMarkAccess( )->getFieldmarkFor( aPosition );
+ ASSERT( pBM != NULL, "Where is my form field bookmark???" );
+ if ( pBM != NULL )
+ {
+ if ( pBM->GetFieldname( ).equalsAscii( ODF_FORMCHECKBOX ) )
+ {
+ Width( rInf.GetTxtHeight( ) );
+ Height( rInf.GetTxtHeight( ) );
+ SetAscent( rInf.GetAscent( ) );
+ }
+ else if ( pBM->GetFieldname( ).equalsAscii( ODF_FORMDROPDOWN ) )
+ {
+ ::rtl::OUString aTxt;
+ getCurrentListIndex( pBM, &aTxt );
+ SwPosSize aPosSize = rInf.GetTxtSize( aTxt );
+ Width( aPosSize.Width( ) );
+ Height( aPosSize.Height( ) );
+ SetAscent( rInf.GetAscent( ) );
+ }
+ else
+ {
+ assert( 0 ); // unknown type...
+ }
+ }
return ret;
}
diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx
index 5f487bce1184..590ddb6e803e 100644
--- a/sw/source/core/unocore/unobkm.cxx
+++ b/sw/source/core/unocore/unobkm.cxx
@@ -49,6 +49,7 @@
#include <docsh.hxx>
+using namespace ::sw::mark;
using namespace ::com::sun::star;
using ::rtl::OUString;
@@ -520,67 +521,131 @@ SwXFieldmark::SwXFieldmark(bool _isReplacementObject, ::sw::mark::IMark* pBkm, S
, isReplacementObject(_isReplacementObject)
{ }
-void SwXFieldmark::attachToRange(const uno::Reference< text::XTextRange > & xTextRange)
- throw( lang::IllegalArgumentException, uno::RuntimeException )
+void SwXFieldmarkParameters::insertByName(const OUString& aName, const uno::Any& aElement)
+ throw (lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException)
{
- attachToRangeEx(xTextRange, (isReplacementObject?IDocumentMarkAccess::CHECKBOX_FIELDMARK:IDocumentMarkAccess::TEXT_FIELDMARK));
+ vos::OGuard aGuard(Application::GetSolarMutex());
+ IFieldmark::parameter_map_t* pParameters = getCoreParameters();
+ if(pParameters->find(aName) != pParameters->end())
+ throw container::ElementExistException();
+ (*pParameters)[aName] = aElement;
}
-::rtl::OUString SwXFieldmark::getDescription(void) throw( ::com::sun::star::uno::RuntimeException )
+void SwXFieldmarkParameters::removeByName(const OUString& aName)
+ throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
-// TODO implement...
-// if(!GetBookmark())
- ::sw::mark::IFieldmark const * const pMark =
- dynamic_cast< ::sw::mark::IFieldmark const * const>(GetBookmark());
- if(!pMark)
- throw uno::RuntimeException();
- return pMark->GetFieldHelptext();
+ if(!getCoreParameters()->erase(aName))
+ throw container::NoSuchElementException();
}
-::sal_Int16 SAL_CALL SwXFieldmark::getType() throw (::com::sun::star::uno::RuntimeException)
+void SwXFieldmarkParameters::replaceByName(const OUString& aName, const uno::Any& aElement)
+ throw (lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- ::sw::mark::ICheckboxFieldmark const * const pAsCheckbox =
- dynamic_cast< ::sw::mark::ICheckboxFieldmark const * const>(GetBookmark());
- if(pAsCheckbox)
- return 1;
- return 0;
+ IFieldmark::parameter_map_t* pParameters = getCoreParameters();
+ IFieldmark::parameter_map_t::iterator pEntry = pParameters->find(aName);
+ if(pEntry == pParameters->end())
+ throw container::NoSuchElementException();
+ pEntry->second = aElement;
}
-::sal_Int16 SAL_CALL SwXFieldmark::getRes() throw (::com::sun::star::uno::RuntimeException)
+uno::Any SwXFieldmarkParameters::getByName(const OUString& aName)
+ throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- ::sw::mark::ICheckboxFieldmark const * const pAsCheckbox =
- dynamic_cast< ::sw::mark::ICheckboxFieldmark const * const>(GetBookmark());
- if(pAsCheckbox && pAsCheckbox->IsChecked())
- return 1;
- return 0;
+ IFieldmark::parameter_map_t* pParameters = getCoreParameters();
+ IFieldmark::parameter_map_t::iterator pEntry = pParameters->find(aName);
+ if(pEntry == pParameters->end())
+ throw container::NoSuchElementException();
+ return pEntry->second;
+}
+
+uno::Sequence<OUString> SwXFieldmarkParameters::getElementNames()
+ throw (uno::RuntimeException)
+{
+ vos::OGuard aGuard(Application::GetSolarMutex());
+ IFieldmark::parameter_map_t* pParameters = getCoreParameters();
+ uno::Sequence<OUString> vResult(pParameters->size());
+ OUString* pOutEntry = vResult.getArray();
+ for(IFieldmark::parameter_map_t::iterator pEntry = pParameters->begin(); pEntry!=pParameters->end(); ++pEntry, ++pOutEntry)
+ *pOutEntry = pEntry->first;
+ return vResult;
+}
+
+::sal_Bool SwXFieldmarkParameters::hasByName(const OUString& aName)
+ throw (uno::RuntimeException)
+{
+ vos::OGuard aGuard(Application::GetSolarMutex());
+ IFieldmark::parameter_map_t* pParameters = getCoreParameters();
+ return (pParameters->find(aName) != pParameters->end());
+}
+
+uno::Type SwXFieldmarkParameters::getElementType()
+ throw (uno::RuntimeException)
+{
+ return ::cppu::UnoType< ::cppu::UnoVoidType>::get();
+}
+
+::sal_Bool SwXFieldmarkParameters::hasElements()
+ throw (uno::RuntimeException)
+{
+ vos::OGuard aGuard(Application::GetSolarMutex());
+ return !getCoreParameters()->empty();
}
-//FIXME Remove Method
-void SAL_CALL SwXFieldmark::setType( ::sal_Int16 ) throw (::com::sun::star::uno::RuntimeException)
+void SwXFieldmarkParameters::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew)
+{
+ ClientModify(this, pOld, pNew);
+}
+
+
+IFieldmark::parameter_map_t* SwXFieldmarkParameters::getCoreParameters()
+ throw (uno::RuntimeException)
+{
+ const IFieldmark* pFieldmark = dynamic_cast< const IFieldmark* >(GetRegisteredIn());
+ if(!pFieldmark)
+ throw uno::RuntimeException();
+ return const_cast< IFieldmark* >(pFieldmark)->GetParameters();
+}
+
+
+void SwXFieldmark::attachToRange( const uno::Reference < text::XTextRange >& xTextRange )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ attachToRangeEx( xTextRange,
+ ( isReplacementObject ? IDocumentMarkAccess::CHECKBOX_FIELDMARK : IDocumentMarkAccess::TEXT_FIELDMARK ) );
+}
+
+::rtl::OUString SwXFieldmark::getFieldType(void)
+ throw(uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- throw uno::RuntimeException();
+ const IFieldmark *pBkm = dynamic_cast<const IFieldmark*>(GetBookmark());
+ if(!pBkm)
+ throw uno::RuntimeException();
+ return pBkm->GetFieldname();
}
-//FIXME Remove Method
-void SAL_CALL SwXFieldmark::setRes( ::sal_Int16 ) throw (::com::sun::star::uno::RuntimeException)
+void SwXFieldmark::setFieldType(const::rtl::OUString & fieldType)
+ throw(uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- throw uno::RuntimeException();
+ IFieldmark *pBkm = const_cast<IFieldmark*>(
+ dynamic_cast<const IFieldmark*>(GetBookmark()));
+ if(!pBkm)
+ throw uno::RuntimeException();
+ pBkm->SetFieldname(fieldType);
}
-void SAL_CALL SwXFieldmark::setDescription( const ::rtl::OUString& description )
- throw (::com::sun::star::uno::RuntimeException)
+uno::Reference<container::XNameContainer> SwXFieldmark::getParameters()
+ throw (uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
- const ::sw::mark::IFieldmark* pMark =
- dynamic_cast<const ::sw::mark::IFieldmark*>(GetBookmark());
- if(pMark)
- const_cast< ::sw::mark::IFieldmark*>(pMark)->SetFieldHelptext(description);
- else
+ IFieldmark *pBkm = const_cast<IFieldmark*>(
+ dynamic_cast<const IFieldmark*>(GetBookmark()));
+ if(!pBkm)
throw uno::RuntimeException();
+ return uno::Reference<container::XNameContainer>(new SwXFieldmarkParameters(pBkm));
}