[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/kspread
From: Robert Knight <robertknight () gmail ! com>
Date: 2006-02-07 18:27:12
Message-ID: 1139336832.780007.20359.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 506848 by knight:
OASIS: Fix loading of cells containing multiple lines of text. BUG:121548
M +57 -22 kspread_cell.cc
M +9 -3 kspread_cell.h
--- trunk/koffice/kspread/kspread_cell.cc #506847:506848
@@ -5593,29 +5593,12 @@
format()->loadOasisStyleProperties( styleStack, oasisContext.oasisStyles() );
loadOasisConditional( style );
}
- QDomElement textP = KoDom::namedItemNS( element, KoXmlNS::text, "p" );
- if ( !textP.isNull() )
- {
- text = textP.text(); // our text, could contain formating for value or result of formul
- setCellText( text );
- setValue( text );
+ // QDomElement textP = KoDom::namedItemNS( element, KoXmlNS::text, "p" );
+
+
+ //Search and load each paragraph of text. Each paragraph is separated by a line break.
+ loadOasisCellText( element );
- QDomElement textA = KoDom::namedItemNS( textP, KoXmlNS::text, "a" );
- if( !textA.isNull() )
- {
- if ( textA.hasAttributeNS( KoXmlNS::xlink, "href" ) )
- {
- QString link = textA.attributeNS( KoXmlNS::xlink, "href", QString::null );
- text = textA.text();
- setCellText( text );
- setValue( text );
- if ( link[0]=='#' )
- link=link.remove( 0, 1 );
- setLink( link );
- }
- }
- }
-
bool isFormula = false;
if ( element.hasAttributeNS( KoXmlNS::table, "formula" ) )
{
@@ -5840,6 +5823,58 @@
return true;
}
+void Cell::loadOasisCellText( const QDomElement& parent )
+{
+ //Search and load each paragraph of text. Each paragraph is separated by a line break
+ QDomElement textParagraphElement;
+ QString cellText;
+
+ bool multipleTextParagraphsFound=false;
+
+ forEachElement( textParagraphElement , parent )
+ {
+ if ( textParagraphElement.localName()=="p" &&
+ textParagraphElement.namespaceURI()== KoXmlNS::text )
+ {
+ // our text, could contain formating for value or result of formul
+ if (cellText.isEmpty())
+ cellText = textParagraphElement.text();
+ else
+ {
+ cellText += "\n"+textParagraphElement.text();
+ multipleTextParagraphsFound=true;
+ }
+
+ QDomElement textA = KoDom::namedItemNS( textParagraphElement, KoXmlNS::text, "a" );
+ if( !textA.isNull() )
+ {
+ if ( textA.hasAttributeNS( KoXmlNS::xlink, "href" ) )
+ {
+ QString link = textA.attributeNS( KoXmlNS::xlink, "href", QString::null );
+ cellText = textA.text();
+ setCellText( cellText );
+ setValue( cellText );
+ if ( link[0]=='#' )
+ link=link.remove( 0, 1 );
+ setLink( link );
+ }
+ }
+ }
+ }
+
+ if (!cellText.isNull())
+ {
+ setCellText( cellText );
+ setValue( cellText );
+ }
+
+ //Enable word wrapping if multiple lines of text have been found.
+ if ( multipleTextParagraphsFound )
+ {
+ format()->setMultiRow(true);
+ }
+}
+
void Cell::loadOasisObjects( const QDomElement &parent, KoOasisLoadingContext& oasisContext )
{
QDomElement e = parent;
--- trunk/koffice/kspread/kspread_cell.h #506847:506848
@@ -267,9 +267,7 @@
bool load( const QDomElement& cell, int _xshift, int _yshift, Paste::Mode pm = Paste::Normal,
Paste::Operation op = Paste::OverWrite, bool paste = false );
- bool loadOasis( const QDomElement & element, KoOasisLoadingContext &oasisContext );
- void loadOasisObjects( const QDomElement& e, KoOasisLoadingContext& oasisContext );
- void loadOasisValidation( const QString& validationName );
+ bool loadOasis( const QDomElement & element, KoOasisLoadingContext &oasisContext );
QTime toTime(const QDomElement &element);
QDate toDate(const QDomElement &element);
@@ -941,6 +939,14 @@
*/
void checkNumberFormat();
+ /**
+ * Load the text paragraphs from an OASIS XML cell description.
+ * @param parent The DOM element representing the cell.
+ */
+ void loadOasisCellText( const QDomElement& parent );
+ void loadOasisObjects( const QDomElement& e, KoOasisLoadingContext& oasisContext );
+ void loadOasisValidation( const QString& validationName );
+
void loadOasisValidationCondition( QString &valExpression );
void saveOasisAnnotation( KoXmlWriter &xmlwriter );
void loadOasisConditional( QDomElement * style );
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic