diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-03-26 17:08:35 +0000 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2014-04-08 11:05:17 +0300 |
commit | 27a15d36e11b90d91ca05bea10a11d29451b9426 (patch) | |
tree | 54d123c13074e289a6fb5a834def4d5a9bcb40b1 /sw | |
parent | 5761abe0813eee11a7b7c6fe3acefd612176b366 (diff) |
Resolves: fdo#73936 make FormFieldDropDowns a real fieldportion
split the checkbox and list and use a field portion for the list.
That way it knows how to line break correctly wrt hardspaces and doesn't hang
when the situation arises.
(cherry picked from commit a52ee51269a47e52d68405caf8507e1abaa6fd8f)
Conflicts:
sw/source/core/text/itrform2.cxx
sw/source/core/text/portxt.cxx
sw/source/core/text/portxt.hxx
Change-Id: I46d73f19ef8e51e7c21c8783ce70bb80d98a784c
Reviewed-on: https://gerrit.libreoffice.org/8776
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/text/inftxt.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/text/inftxt.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/text/itrform2.cxx | 48 | ||||
-rw-r--r-- | sw/source/core/text/porfld.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/text/porfld.hxx | 15 | ||||
-rw-r--r-- | sw/source/core/text/portxt.cxx | 82 | ||||
-rw-r--r-- | sw/source/core/text/portxt.hxx | 9 |
7 files changed, 87 insertions, 80 deletions
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index adf78faa21c7..8d03d84d9415 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -1056,7 +1056,7 @@ void SwTxtPaintInfo::DrawPostIts( const SwLinePortion&, sal_Bool bScript ) const } } -void SwTxtPaintInfo::DrawCheckBox( const SwFieldFormPortion &rPor, bool checked) const +void SwTxtPaintInfo::DrawCheckBox(const SwFieldFormCheckboxPortion &rPor, bool bChecked) const { SwRect aIntersect; CalcRect( rPor, &aIntersect, 0 ); @@ -1078,7 +1078,8 @@ void SwTxtPaintInfo::DrawCheckBox( const SwFieldFormPortion &rPor, bool checked) m_pOut->SetLineColor( Color(0, 0, 0)); m_pOut->SetFillColor(); m_pOut->DrawRect( r ); - if (checked) { + if (bChecked) + { m_pOut->DrawLine(r.TopLeft(), r.BottomRight()); m_pOut->DrawLine(r.TopRight(), r.BottomLeft()); } diff --git a/sw/source/core/text/inftxt.hxx b/sw/source/core/text/inftxt.hxx index 2127221d8a84..8c3ed9a691d8 100644 --- a/sw/source/core/text/inftxt.hxx +++ b/sw/source/core/text/inftxt.hxx @@ -450,7 +450,7 @@ public: **/ void DrawBorder( const SwLinePortion &rPor ) const; - void DrawCheckBox( const SwFieldFormPortion &rPor, bool checked) const; + void DrawCheckBox(const SwFieldFormCheckboxPortion &rPor, bool bChecked) const; inline void NotifyURL( const SwLinePortion &rPor ) const { if( URLNotify() ) _NotifyURL( rPor ); } diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index 12c58e46e714..9cb57bcee00c 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -55,6 +55,7 @@ #include <doc.hxx> #include <pormulti.hxx> #include <unotools/charclass.hxx> +#include <xmloff/odffields.hxx> #include <vector> @@ -876,11 +877,31 @@ void SwMetaPortion::Paint( const SwTxtPaintInfo &rInf ) const } } +namespace { + using namespace sw::mark; + static OUString getCurrentListIndex(IFieldmark* pBM) + { + const IFieldmark::parameter_map_t* const pParameters = pBM->GetParameters(); + sal_Int32 nCurrentIdx = 0; + const IFieldmark::parameter_map_t::const_iterator pResult = pParameters->find(OUString(ODF_FORMDROPDOWN_RESULT)); + if(pResult != pParameters->end()) + pResult->second >>= nCurrentIdx; + + const IFieldmark::parameter_map_t::const_iterator pListEntries = pParameters->find(OUString(ODF_FORMDROPDOWN_LISTENTRY)); + if (pListEntries != pParameters->end()) + { + uno::Sequence< OUString > vListEntries; + pListEntries->second >>= vListEntries; + if (nCurrentIdx < vListEntries.getLength()) + return vListEntries[nCurrentIdx]; + } + return OUString(); + } +} /************************************************************************* * SwTxtFormatter::WhichTxtPor() *************************************************************************/ - SwTxtPortion *SwTxtFormatter::WhichTxtPor( SwTxtFormatInfo &rInf ) const { SwTxtPortion *pPor = 0; @@ -912,7 +933,29 @@ SwTxtPortion *SwTxtFormatter::WhichTxtPor( SwTxtFormatInfo &rInf ) const else if( rInf.GetTxt()[rInf.GetIdx()]==CH_TXT_ATR_FIELDEND ) pPor = new SwFieldMarkPortion(); else if( rInf.GetTxt()[rInf.GetIdx()]==CH_TXT_ATR_FORMELEMENT ) - pPor = new SwFieldFormPortion(); + { + SwTxtNode *pNd = const_cast<SwTxtNode *>(rInf.GetTxtFrm()->GetTxtNode()); + const SwDoc *doc = pNd->GetDoc(); + SwIndex aIndex(pNd, rInf.GetIdx()); + SwPosition aPosition(*pNd, aIndex); + sw::mark::IFieldmark *pBM = doc->getIDocumentMarkAccess()->getFieldmarkFor(aPosition); + OSL_ENSURE(pBM != NULL, "Where is my form field bookmark???"); + if (pBM != NULL) + { + if (pBM->GetFieldname( ) == ODF_FORMCHECKBOX) + { + pPor = new SwFieldFormCheckboxPortion(); + } + else if (pBM->GetFieldname( ) == ODF_FORMDROPDOWN) + { + pPor = new SwFieldFormDropDownPortion(getCurrentListIndex(pBM)); + } + else + { + assert( false ); // unknown type... + } + } + } } if( !pPor ) { @@ -1010,7 +1053,6 @@ SwTxtPortion *SwTxtFormatter::NewTxtPortion( SwTxtFormatInfo &rInf ) /************************************************************************* * SwTxtFormatter::WhichFirstPortion() *************************************************************************/ - SwLinePortion *SwTxtFormatter::WhichFirstPortion(SwTxtFormatInfo &rInf) { SwLinePortion *pPor = 0; diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx index b0c57acf4cb8..f2f5a0fa4a7b 100644 --- a/sw/source/core/text/porfld.cxx +++ b/sw/source/core/text/porfld.cxx @@ -40,7 +40,6 @@ #include <porftn.hxx> #include <accessibilityoptions.hxx> #include <editeng/lrspitem.hxx> - #include <unicode/ubidi.h> using namespace ::com::sun::star; @@ -1352,4 +1351,9 @@ KSHORT SwCombinedPortion::GetViewWidth( const SwTxtSizeInfo &rInf ) const return SwFldPortion::GetViewWidth( rInf ); } +SwFldPortion *SwFieldFormDropDownPortion::Clone(const OUString &rExpand) const +{ + return new SwFieldFormDropDownPortion(rExpand); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/text/porfld.hxx b/sw/source/core/text/porfld.hxx index ef9f9567f7a2..16ab8581d56f 100644 --- a/sw/source/core/text/porfld.hxx +++ b/sw/source/core/text/porfld.hxx @@ -246,6 +246,21 @@ public: OUTPUT_OPERATOR }; +namespace sw { namespace mark { + class IFieldmark; +} } + +class SwFieldFormDropDownPortion : public SwFldPortion +{ +public: + SwFieldFormDropDownPortion(const OUString &rExpand) + : SwFldPortion(rExpand) + { + } + // Field cloner for SplitGlue + virtual SwFldPortion *Clone( const OUString &rExpand ) const; +}; + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx index 68a290bd4e17..b6ee27e4f91a 100644 --- a/sw/source/core/text/portxt.cxx +++ b/sw/source/core/text/portxt.cxx @@ -916,32 +916,7 @@ sal_Bool SwFieldMarkPortion::Format( SwTxtFormatInfo & ) return ret; } -namespace { - static sal_Int32 getCurrentListIndex( IFieldmark* pBM, - 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(OUString(ODF_FORMDROPDOWN_RESULT)); - if(pResult != pParameters->end()) - pResult->second >>= nCurrentIdx; - if(io_pCurrentText) - { - const IFieldmark::parameter_map_t::const_iterator pListEntries = pParameters->find(OUString(ODF_FORMDROPDOWN_LISTENTRY)); - if(pListEntries != pParameters->end()) - { - uno::Sequence< 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 SwFieldFormCheckboxPortion::Paint( const SwTxtPaintInfo& rInf ) const { SwTxtNode* pNd = const_cast<SwTxtNode*>(rInf.GetTxtFrm()->GetTxtNode()); const SwDoc *doc=pNd->GetDoc(); @@ -950,33 +925,18 @@ void SwFieldFormPortion::Paint( const SwTxtPaintInfo& rInf ) const IFieldmark* pBM = doc->getIDocumentMarkAccess( )->getFieldmarkFor( aPosition ); - OSL_ENSURE( pBM, - "SwFieldFormPortion::Paint(..)" - " - Where is my form field bookmark???"); + OSL_ENSURE(pBM && pBM->GetFieldname( ) == ODF_FORMCHECKBOX, + "Where is my form field bookmark???"); - if ( pBM != NULL ) + if (pBM && pBM->GetFieldname( ) == ODF_FORMCHECKBOX) { - if ( pBM->GetFieldname( ) == ODF_FORMCHECKBOX ) - { // a checkbox... - ICheckboxFieldmark* pCheckboxFm = dynamic_cast< ICheckboxFieldmark* >(pBM); - bool checked = pCheckboxFm->IsChecked(); - rInf.DrawCheckBox(*this, checked); - } - else if ( pBM->GetFieldname( ) == ODF_FORMDROPDOWN ) - { // a list... - OUString aTxt; - getCurrentListIndex( pBM, &aTxt ); - rInf.DrawViewOpt( *this, POR_FLD ); - rInf.DrawText( aTxt, *this, 0, aTxt.getLength(), false ); - } - else - { - assert(0); // unknown type... - } + const ICheckboxFieldmark* pCheckboxFm = dynamic_cast< ICheckboxFieldmark* >(pBM); + bool bChecked = pCheckboxFm && pCheckboxFm->IsChecked(); + rInf.DrawCheckBox(*this, bChecked); } } -sal_Bool SwFieldFormPortion::Format( SwTxtFormatInfo & rInf ) +sal_Bool SwFieldFormCheckboxPortion::Format( SwTxtFormatInfo & rInf ) { sal_Bool ret = 0; SwTxtNode *pNd = const_cast < SwTxtNode * >( rInf.GetTxtFrm( )->GetTxtNode( ) ); @@ -984,28 +944,12 @@ sal_Bool SwFieldFormPortion::Format( SwTxtFormatInfo & rInf ) SwIndex aIndex( pNd, rInf.GetIdx( ) ); SwPosition aPosition( *pNd, aIndex ); IFieldmark *pBM = doc->getIDocumentMarkAccess( )->getFieldmarkFor( aPosition ); - OSL_ENSURE( pBM != NULL, "Where is my form field bookmark???" ); - if ( pBM != NULL ) + OSL_ENSURE(pBM && pBM->GetFieldname( ) == ODF_FORMCHECKBOX, "Where is my form field bookmark???"); + if (pBM && pBM->GetFieldname( ) == ODF_FORMCHECKBOX) { - if ( pBM->GetFieldname( ) == ODF_FORMCHECKBOX ) - { - Width( rInf.GetTxtHeight( ) ); - Height( rInf.GetTxtHeight( ) ); - SetAscent( rInf.GetAscent( ) ); - } - else if ( pBM->GetFieldname( ) == ODF_FORMDROPDOWN ) - { - OUString aTxt; - getCurrentListIndex( pBM, &aTxt ); - SwPosSize aPosSize = rInf.GetTxtSize( aTxt ); - Width( aPosSize.Width( ) ); - Height( aPosSize.Height( ) ); - SetAscent( rInf.GetAscent( ) ); - } - else - { - assert( 0 ); // unknown type... - } + Width( rInf.GetTxtHeight( ) ); + Height( rInf.GetTxtHeight( ) ); + SetAscent( rInf.GetAscent( ) ); } return ret; } diff --git a/sw/source/core/text/portxt.hxx b/sw/source/core/text/portxt.hxx index 71e6de5a3ebd..4cec8cf8774a 100644 --- a/sw/source/core/text/portxt.hxx +++ b/sw/source/core/text/portxt.hxx @@ -108,11 +108,12 @@ class SwFieldMarkPortion : public SwTxtPortion virtual sal_Bool Format( SwTxtFormatInfo &rInf ); }; -class SwFieldFormPortion : public SwTxtPortion +class SwFieldFormCheckboxPortion : public SwTxtPortion { - public: - inline SwFieldFormPortion() : SwTxtPortion() - { } +public: + SwFieldFormCheckboxPortion() : SwTxtPortion() + { + } virtual void Paint( const SwTxtPaintInfo &rInf ) const; virtual sal_Bool Format( SwTxtFormatInfo &rInf ); }; |