[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - 2 commits - include/xmloff sw/inc sw/source
Tamás Zolnai (via logerrit)
logerrit at kemper.freedesktop.org
Sat Jul 13 22:15:31 UTC 2019
include/xmloff/odffields.hxx | 2
sw/inc/IDocumentMarkAccess.hxx | 1
sw/source/core/crsr/bookmrk.cxx | 91 ++++++++++++++++++++++++++------------
sw/source/core/doc/docbm.cxx | 18 +++++++
sw/source/core/inc/bookmrk.hxx | 38 +++++++++++++--
sw/source/core/text/itrform2.cxx | 10 ++++
sw/source/core/text/porfld.cxx | 18 +++++++
sw/source/core/text/porfld.hxx | 17 +++++++
sw/source/core/unocore/unobkm.cxx | 4 +
9 files changed, 164 insertions(+), 35 deletions(-)
New commits:
commit 298bde7f09947364d915cbf0c74f9156c52b62fe
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Fri May 31 17:34:51 2019 +0200
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Sun Jul 14 00:15:00 2019 +0200
MSForms: Introduce a new fieldmark class for text-based date field
Reviewed-on: https://gerrit.libreoffice.org/75437
Tested-by: Jenkins
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 0fd05f6503c42df35b16735c7b690e56f1acab30)
Change-Id: I3df49c516603fb16601fc0a9c13c6d9ea401207a
Reviewed-on: https://gerrit.libreoffice.org/75531
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Andras Timar <andras.timar at collabora.com>
diff --git a/include/xmloff/odffields.hxx b/include/xmloff/odffields.hxx
index 27525fb39374..82127a57628e 100644
--- a/include/xmloff/odffields.hxx
+++ b/include/xmloff/odffields.hxx
@@ -33,6 +33,8 @@
#define ODF_FORMDROPDOWN_LISTENTRY "Dropdown_ListEntry"
#define ODF_FORMDROPDOWN_RESULT "Dropdown_Selected"
+#define ODF_FORMDATE "vnd.oasis.opendocument.field.FORMDATE"
+
#define ODF_TOC "vnd.oasis.opendocument.field.TOC"
#define ODF_HYPERLINK "vnd.oasis.opendocument.field.HYPERLINK"
diff --git a/sw/inc/IDocumentMarkAccess.hxx b/sw/inc/IDocumentMarkAccess.hxx
index d7111112612f..ee021ad7c4e4 100644
--- a/sw/inc/IDocumentMarkAccess.hxx
+++ b/sw/inc/IDocumentMarkAccess.hxx
@@ -49,6 +49,7 @@ class IDocumentMarkAccess
TEXT_FIELDMARK,
CHECKBOX_FIELDMARK,
DROPDOWN_FIELDMARK,
+ DATE_FIELDMARK,
NAVIGATOR_REMINDER
};
diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index ba9dce8080c4..fea8530426cd 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -533,6 +533,60 @@ namespace sw { namespace mark
if(m_pButton)
m_pButton.disposeAndClear();
}
+
+ DateFieldmark::DateFieldmark(const SwPaM& rPaM)
+ : NonTextFieldmark(rPaM)
+ //, m_pButton(nullptr)
+ {
+ }
+
+ DateFieldmark::~DateFieldmark()
+ {
+ //m_pButton.disposeAndClear();
+ (void)m_pButton;
+ }
+
+ void DateFieldmark::SetPortionPaintArea(const SwRect& /*rPortionPaintArea*/)
+ {
+ /*if(m_aPortionPaintArea == rPortionPaintArea &&
+ m_pButton && m_pButton->IsVisible())
+ return;
+
+ m_aPortionPaintArea = rPortionPaintArea;
+ if(m_pButton)
+ {
+ m_pButton->Show();
+ m_pButton->CalcPosAndSize(m_aPortionPaintArea);
+ m_pButton->Invalidate();
+ }*/
+ (void)m_pButton;
+ }
+
+ void DateFieldmark::ShowButton(SwEditWin* pEditWin)
+ {
+ if(pEditWin)
+ {
+ //if(!m_pButton)
+ // m_pButton = VclPtr<DropDownFormFieldButton>::Create(pEditWin, *this);
+ //m_pButton->CalcPosAndSize(m_aPortionPaintArea);
+ //m_pButton->Show();
+ }
+ (void)m_pButton;
+ }
+
+ void DateFieldmark::HideButton()
+ {
+ //if(m_pButton)
+ //m_pButton->Show(false);
+ (void)m_pButton;
+ }
+
+ void DateFieldmark::RemoveButton()
+ {
+ //if(m_pButton)
+ //m_pButton.disposeAndClear();
+ (void)m_pButton;
+ }
}}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index a7ee56eafca9..a49af25432d3 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -341,6 +341,8 @@ IDocumentMarkAccess::MarkType IDocumentMarkAccess::GetType(const IMark& rBkmk)
return MarkType::CHECKBOX_FIELDMARK;
else if(*pMarkTypeInfo == typeid(DropDownFieldmark))
return MarkType::DROPDOWN_FIELDMARK;
+ else if(*pMarkTypeInfo == typeid(DateFieldmark))
+ return MarkType::DATE_FIELDMARK;
else if(*pMarkTypeInfo == typeid(NavigatorReminder))
return MarkType::NAVIGATOR_REMINDER;
else
@@ -421,6 +423,9 @@ namespace sw { namespace mark
case IDocumentMarkAccess::MarkType::DROPDOWN_FIELDMARK:
pMark = std::shared_ptr<IMark>(new DropDownFieldmark(rPaM));
break;
+ case IDocumentMarkAccess::MarkType::DATE_FIELDMARK:
+ pMark = std::make_unique<DateFieldmark>(rPaM);
+ break;
case IDocumentMarkAccess::MarkType::NAVIGATOR_REMINDER:
pMark = std::shared_ptr<IMark>(new NavigatorReminder(rPaM));
break;
@@ -471,6 +476,7 @@ namespace sw { namespace mark
case IDocumentMarkAccess::MarkType::TEXT_FIELDMARK:
case IDocumentMarkAccess::MarkType::CHECKBOX_FIELDMARK:
case IDocumentMarkAccess::MarkType::DROPDOWN_FIELDMARK:
+ case IDocumentMarkAccess::MarkType::DATE_FIELDMARK:
lcl_InsertMarkSorted(m_vFieldmarks, pMark);
break;
case IDocumentMarkAccess::MarkType::ANNOTATIONMARK:
@@ -545,6 +551,12 @@ namespace sw { namespace mark
IDocumentMarkAccess::MarkType::DROPDOWN_FIELDMARK,
sw::mark::InsertMode::New);
}
+ else if(rType == ODF_FORMDATE)
+ {
+ pMark = makeMark( rPaM, rName,
+ IDocumentMarkAccess::MarkType::DATE_FIELDMARK,
+ sw::mark::InsertMode::New);
+ }
sw::mark::IFieldmark* pFieldMark = dynamic_cast<sw::mark::IFieldmark*>( pMark );
if (pFieldMark)
@@ -959,6 +971,7 @@ namespace sw { namespace mark
case IDocumentMarkAccess::MarkType::TEXT_FIELDMARK:
case IDocumentMarkAccess::MarkType::CHECKBOX_FIELDMARK:
case IDocumentMarkAccess::MarkType::DROPDOWN_FIELDMARK:
+ case IDocumentMarkAccess::MarkType::DATE_FIELDMARK:
{
IDocumentMarkAccess::iterator_t ppFieldmark = lcl_FindMark(m_vFieldmarks, *ppMark);
if ( ppFieldmark != m_vFieldmarks.end() )
@@ -1121,6 +1134,11 @@ namespace sw { namespace mark
if (dynamic_cast<::sw::mark::DropDownFieldmark*>(pFieldmark))
bActualChange = true;
}
+ else if(rNewType == ODF_FORMDATE)
+ {
+ if (dynamic_cast<::sw::mark::DateFieldmark*>(pFieldmark))
+ bActualChange = true;
+ }
if (!bActualChange)
return nullptr;
diff --git a/sw/source/core/inc/bookmrk.hxx b/sw/source/core/inc/bookmrk.hxx
index aa1816096bea..75968a5d01e1 100644
--- a/sw/source/core/inc/bookmrk.hxx
+++ b/sw/source/core/inc/bookmrk.hxx
@@ -277,6 +277,26 @@ namespace sw {
SwRect m_aPortionPaintArea;
VclPtr<DropDownFormFieldButton> m_pButton;
};
+
+ /// Fieldmark representing a date form field.
+ class DateFieldmark
+ : public NonTextFieldmark
+ {
+ public:
+ DateFieldmark(const SwPaM& rPaM);
+ virtual ~DateFieldmark() override;
+
+ // This method should be called only by the portion so we can now the portion's painting area
+ void SetPortionPaintArea(const SwRect& rPortionPaintArea);
+
+ void ShowButton(SwEditWin* pEditWin);
+ void HideButton();
+ void RemoveButton();
+
+ private:
+ SwRect m_aPortionPaintArea;
+ VclPtr<MenuButton> m_pButton;
+ };
}
}
#endif
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index 0fd7f0bb4c76..c55195faa8eb 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -860,6 +860,12 @@ namespace sw { namespace mark {
sal_Unicode vEnSpaces[ODF_FORMFIELD_DEFAULT_LENGTH] = {8194, 8194, 8194, 8194, 8194};
return OUString(vEnSpaces, ODF_FORMFIELD_DEFAULT_LENGTH);
}
+
+ static OUString ExpandDateFieldmark(IFieldmark* /*pBM*/)
+ {
+ sal_Unicode vEnSpaces[ODF_FORMFIELD_DEFAULT_LENGTH] = {8194, 8194, 8194, 8194, 8194};
+ return OUString(vEnSpaces, ODF_FORMFIELD_DEFAULT_LENGTH);
+ }
} }
SwTextPortion *SwTextFormatter::WhichTextPor( SwTextFormatInfo &rInf ) const
@@ -908,6 +914,10 @@ SwTextPortion *SwTextFormatter::WhichTextPor( SwTextFormatInfo &rInf ) const
{
pPor = new SwFieldFormDropDownPortion(pBM, sw::mark::ExpandFieldmark(pBM));
}
+ else if (pBM->GetFieldname( ) == ODF_FORMDATE)
+ {
+ pPor = new SwFieldFormDatePortion(pBM, sw::mark::ExpandDateFieldmark(pBM));
+ }
/* we need to check for ODF_FORMTEXT for scenario having FormFields inside FORMTEXT.
* Otherwise file will crash on open.
*/
diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx
index de30d4e9cfc3..af29eaec97fe 100644
--- a/sw/source/core/text/porfld.cxx
+++ b/sw/source/core/text/porfld.cxx
@@ -1332,4 +1332,22 @@ void SwFieldFormDropDownPortion::Paint( const SwTextPaintInfo &rInf ) const
}
}
+SwFieldPortion *SwFieldFormDatePortion::Clone(const OUString &rExpand) const
+{
+ return new SwFieldFormDatePortion(m_pFieldMark, rExpand);
+}
+
+void SwFieldFormDatePortion::Paint( const SwTextPaintInfo &rInf ) const
+{
+ SwFieldPortion::Paint( rInf );
+
+ ::sw::mark::DateFieldmark* pDateField = dynamic_cast< ::sw::mark::DateFieldmark* >(m_pFieldMark);
+ if(pDateField)
+ {
+ SwRect aPaintArea;
+ rInf.CalcRect( *this, &aPaintArea );
+ pDateField->SetPortionPaintArea(aPaintArea);
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/porfld.hxx b/sw/source/core/text/porfld.hxx
index a18f1343451b..f16b1b2e7c1c 100644
--- a/sw/source/core/text/porfld.hxx
+++ b/sw/source/core/text/porfld.hxx
@@ -240,6 +240,23 @@ private:
sw::mark::IFieldmark* m_pFieldMark;
};
+class SwFieldFormDatePortion : public SwFieldPortion
+{
+public:
+ explicit SwFieldFormDatePortion(sw::mark::IFieldmark *pFieldMark, const OUString &rExpand)
+ : SwFieldPortion(rExpand)
+ , m_pFieldMark(pFieldMark)
+ {
+ }
+ // Field cloner for SplitGlue
+ virtual SwFieldPortion *Clone( const OUString &rExpand ) const override;
+
+ virtual void Paint( const SwTextPaintInfo &rInf ) const override;
+
+private:
+ sw::mark::IFieldmark* m_pFieldMark;
+};
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx
index 7b2d93467316..ed058fb3ccd6 100644
--- a/sw/source/core/unocore/unobkm.cxx
+++ b/sw/source/core/unocore/unobkm.cxx
@@ -558,7 +558,7 @@ void SwXFieldmark::setFieldType(const OUString & fieldType)
throw uno::RuntimeException();
if(fieldType != getFieldType())
{
- if(fieldType == ODF_FORMDROPDOWN || fieldType == ODF_FORMCHECKBOX)
+ if(fieldType == ODF_FORMDROPDOWN || fieldType == ODF_FORMCHECKBOX || fieldType == ODF_FORMDATE)
{
::sw::mark::IFieldmark* pNewFieldmark = GetIDocumentMarkAccess()->changeNonTextFieldmarkType(pBkm, fieldType);
if (pNewFieldmark)
@@ -606,6 +606,8 @@ SwXFieldmark::CreateXFieldmark(SwDoc & rDoc, ::sw::mark::IMark *const pMark,
pXBkmk = new SwXFieldmark(true, &rDoc);
else if (dynamic_cast< ::sw::mark::DropDownFieldmark* >(pMark))
pXBkmk = new SwXFieldmark(true, &rDoc);
+ else if (dynamic_cast< ::sw::mark::DateFieldmark* >(pMark))
+ pXBkmk = new SwXFieldmark(true, &rDoc);
else
pXBkmk = new SwXFieldmark(isReplacementObject, &rDoc);
commit 0e82127ff4f6f7eea4fedbbb795f85713ccbf16b
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Wed Apr 3 12:11:44 2019 +0200
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Sun Jul 14 00:14:46 2019 +0200
MSForms: Deduplicate code by creating NonTextFieldmark class
CheckboxFieldmark and DropDownFieldmark do the same in
their InitDoc() and ReleaseDoc() methods.
Change-Id: If6acae7f4783a222bc225c19ce8d32ea22f0d20b
Reviewed-on: https://gerrit.libreoffice.org/75436
Tested-by: Jenkins
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 74bb3277e1471db2840584469a00158174780bd9)
Reviewed-on: https://gerrit.libreoffice.org/75530
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Andras Timar <andras.timar at collabora.com>
diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index 1b29071f38d5..ba9dce8080c4 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -431,11 +431,11 @@ namespace sw { namespace mark
lcl_RemoveFieldMarks(this, pDoc, CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FIELDEND);
}
- CheckboxFieldmark::CheckboxFieldmark(const SwPaM& rPaM)
+ NonTextFieldmark::NonTextFieldmark(const SwPaM& rPaM)
: Fieldmark(rPaM)
{ }
- void CheckboxFieldmark::InitDoc(SwDoc* const io_pDoc, sw::mark::InsertMode const eMode)
+ void NonTextFieldmark::InitDoc(SwDoc* const io_pDoc, sw::mark::InsertMode const eMode)
{
if (eMode == sw::mark::InsertMode::New)
{
@@ -453,12 +453,17 @@ namespace sw { namespace mark
}
}
- void CheckboxFieldmark::ReleaseDoc(SwDoc* const pDoc)
+ void NonTextFieldmark::ReleaseDoc(SwDoc* const pDoc)
{
lcl_RemoveFieldMarks(this, pDoc,
CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FORMELEMENT);
}
+
+ CheckboxFieldmark::CheckboxFieldmark(const SwPaM& rPaM)
+ : NonTextFieldmark(rPaM)
+ { }
+
void CheckboxFieldmark::SetChecked(bool checked)
{
if ( IsChecked() != checked )
@@ -481,7 +486,7 @@ namespace sw { namespace mark
}
DropDownFieldmark::DropDownFieldmark(const SwPaM& rPaM)
- : Fieldmark(rPaM)
+ : NonTextFieldmark(rPaM)
, m_pButton(nullptr)
{
}
@@ -491,30 +496,6 @@ namespace sw { namespace mark
m_pButton.disposeAndClear();
}
- void DropDownFieldmark::InitDoc(SwDoc* const io_pDoc, sw::mark::InsertMode const eMode)
- {
- if (eMode == sw::mark::InsertMode::New)
- {
- lcl_SetFieldMarks(this, io_pDoc, CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FORMELEMENT);
-
- // For some reason the end mark is moved from 1 by the Insert:
- // we don't want this for checkboxes
- SwPosition aNewEndPos = GetMarkEnd();
- aNewEndPos.nContent--;
- SetMarkEndPos( aNewEndPos );
- }
- else
- {
- lcl_AssertFieldMarksSet(this, CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FORMELEMENT);
- }
- }
-
- void DropDownFieldmark::ReleaseDoc(SwDoc* const pDoc)
- {
- lcl_RemoveFieldMarks(this, pDoc,
- CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FORMELEMENT);
- }
-
void DropDownFieldmark::SetPortionPaintArea(const SwRect& rPortionPaintArea)
{
if(m_aPortionPaintArea == rPortionPaintArea &&
diff --git a/sw/source/core/inc/bookmrk.hxx b/sw/source/core/inc/bookmrk.hxx
index c1deca2ea810..aa1816096bea 100644
--- a/sw/source/core/inc/bookmrk.hxx
+++ b/sw/source/core/inc/bookmrk.hxx
@@ -237,28 +237,34 @@ namespace sw {
virtual void ReleaseDoc(SwDoc* const pDoc) override;
};
+ // Non text fieldmarks has has no content between the start and end marks.
+ class NonTextFieldmark
+ : public Fieldmark
+ {
+ public:
+ NonTextFieldmark(const SwPaM& rPaM);
+ virtual void InitDoc(SwDoc* const io_pDoc, sw::mark::InsertMode eMode) override;
+ virtual void ReleaseDoc(SwDoc* const pDoc) override;
+ };
+
/// Fieldmark representing a checkbox form field.
class CheckboxFieldmark
: virtual public ICheckboxFieldmark
- , public Fieldmark
+ , public NonTextFieldmark
{
public:
CheckboxFieldmark(const SwPaM& rPaM);
- virtual void InitDoc(SwDoc* const io_pDoc, sw::mark::InsertMode eMode) override;
- virtual void ReleaseDoc(SwDoc* const pDoc) override;
bool IsChecked() const override;
void SetChecked(bool checked) override;
};
/// Fieldmark representing a drop-down form field.
class DropDownFieldmark
- : public Fieldmark
+ : public NonTextFieldmark
{
public:
DropDownFieldmark(const SwPaM& rPaM);
virtual ~DropDownFieldmark() override;
- virtual void InitDoc(SwDoc* const io_pDoc, sw::mark::InsertMode eMode) override;
- virtual void ReleaseDoc(SwDoc* const pDoc) override;
// This method should be called only by the portion so we can now the portion's painting area
void SetPortionPaintArea(const SwRect& rPortionPaintArea);
More information about the Libreoffice-commits
mailing list