Bugzilla – Attachment 96422 Details for
Bug 73936
FILEOPEN: Can't open .doc file: Writer freezes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
rework the dropdown portion to be a fldportion
0001-Resolves-fdo-73936-make-FormFieldDropDowns-a-real-fi.patch (text/plain), 11.79 KB, created by
Caolán McNamara
on 2014-03-26 17:10:53 UTC
(
hide
)
Description:
rework the dropdown portion to be a fldportion
Filename:
MIME Type:
Creator:
Caolán McNamara
Created:
2014-03-26 17:10:53 UTC
Size:
11.79 KB
patch
obsolete
>From 27c6982d4ca89eddeda8e3684699a1219786e18e Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com> >Date: Wed, 26 Mar 2014 17:08:35 +0000 >Subject: [PATCH] Resolves: fdo#73936 make FormFieldDropDowns a real > fieldportion > >Change-Id: I46d73f19ef8e51e7c21c8783ce70bb80d98a784c >--- > sw/source/core/text/inftxt.cxx | 5 ++- > sw/source/core/text/inftxt.hxx | 2 +- > sw/source/core/text/itrform2.cxx | 47 +++++++++++++++++++++- > sw/source/core/text/porfld.cxx | 6 ++- > sw/source/core/text/porfld.hxx | 15 +++++++ > sw/source/core/text/portxt.cxx | 84 +++++++--------------------------------- > sw/source/core/text/portxt.hxx | 9 +++-- > 7 files changed, 88 insertions(+), 80 deletions(-) > >diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx >index adf78fa..8d03d84 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 2127221..8c3ed9a 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 12c58e4..61a86a3 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 ) > { >diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx >index b0c57ac..f2f5a0f 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 ef9f956..16ab858 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 68a290bd..7136d9c 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... >- } >+ ICheckboxFieldmark* pCheckboxFm = dynamic_cast< ICheckboxFieldmark* >(pBM); >+ bool checked = pCheckboxFm->IsChecked(); >+ rInf.DrawCheckBox(*this, checked); > } > } > >-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,31 +944,15 @@ 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; > } > >- > /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ >diff --git a/sw/source/core/text/portxt.hxx b/sw/source/core/text/portxt.hxx >index 71e6de5..4cec8cf 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 ); > }; >-- >1.8.5.3 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 73936
:
92595
|
92621
|
92676
|
92677
|
94243
| 96422