Commits

Kohei Yoshida  committed bdc679e

Renamed a bunch of symbols to make them short and sweet.

Also, put the PhoneticPortion struct inside ScPhonetic.

  • Participants
  • Parent commits 2a9ed9a

Comments (0)

Files changed (9)

File sc/inc/phonetic.hxx

 
 #include <vector>
 
-struct PhoneticPortion
-{
-    sal_uInt16          mncpa;  /// position of the first character in the phonetic text
-    sal_uInt16          mncpm;  /// position of the first character in the base text
-    sal_uInt16          mnccm;  /// length of the characters in the base text
-    explicit inline     PhoneticPortion() : mncpa( 0 ), mncpm( 0 ), mnccm( 0 ) {}
-    explicit inline     PhoneticPortion( sal_uInt16 ncpa, sal_uInt16 ncpm, sal_uInt16 nccm ) :
-                            mncpa( ncpa ), mncpm( ncpm ), mnccm ( nccm ) {}
-};
-
-inline bool operator==( const PhoneticPortion& rLeft, const PhoneticPortion& rRight )
-{
-    return
-        ( rLeft.mncpa == rRight.mncpa ) &&
-        ( rLeft.mncpm == rRight.mncpm ) &&
-        ( rLeft.mnccm == rRight.mnccm );
-}
-
-typedef ::std::vector< PhoneticPortion > PhoneticPortionVec;
-
 /*
  * A class for store Asian phonetic guide information.
  */
 class SC_DLLPUBLIC ScPhonetic
 {
 public:
+    struct Portion
+    {
+        sal_uInt16          mncpa;  /// position of the first character in the phonetic text
+        sal_uInt16          mncpm;  /// position of the first character in the base text
+        sal_uInt16          mnccm;  /// length of the characters in the base text
+        explicit inline     Portion() : mncpa( 0 ), mncpm( 0 ), mnccm( 0 ) {}
+        explicit inline     Portion( sal_uInt16 ncpa, sal_uInt16 ncpm, sal_uInt16 nccm ) :
+                                mncpa( ncpa ), mncpm( ncpm ), mnccm ( nccm ) {}
+    
+        bool operator== (const Portion& r) const
+        {
+            return mncpa == r.mncpa && mncpm == r.mncpm && mnccm == r.mnccm;
+        }
+    };
+
+    typedef ::std::vector< Portion > PortionVec;
+
 	ScPhonetic();
     ScPhonetic(const ScPhonetic& r);
 	ScPhonetic( sal_uInt16 nFontIdx, sal_uInt16 nAdditionalSettings,
                 sal_uInt16 nRepeatedTotalLength, const String& rPhoneticString,
-                const PhoneticPortionVec& rPhoneticPortions );
+                const PortionVec& rPhoneticPortions );
 
 	~ScPhonetic();
 
 	/** Returns the text for phonetic information. */
 	const String& GetString() const;
     /** Returns the portion for phonetic information. */
-	const PhoneticPortionVec& GetPortions() const;
+	const PortionVec& GetPortions() const;
     /** Returns font index of phonetic information. */
 	sal_uInt16 GetFontIndex() const;
     /** Returns additional settings of phonetic information. */
 	sal_uInt32 GetSize() const;
 
 private:
-	PhoneticPortionVec maPhoneticPortions;
-	String             maPhoneticString;
-	sal_uInt16         mnFontIdx;            /// Index to FONT record
-	sal_uInt16         mnAdditionalSettings; /// Additional settings for the Asian phonetic text
-	sal_uInt16         mnRepeatedTotalLength;
+	PortionVec  maPhoneticPortions;
+	String      maPhoneticString;
+	sal_uInt16  mnFontIdx;            /// Index to FONT record
+	sal_uInt16  mnAdditionalSettings; /// Additional settings for the Asian phonetic text
+	sal_uInt16  mnRepeatedTotalLength;
 };
 
 #endif

File sc/source/core/data/phonetic.cxx

 
 ScPhonetic::ScPhonetic( sal_uInt16 nFontIdx, sal_uInt16 nAdditionalSettings, 
                         sal_uInt16 nRepeatedTotalLength, const String& rPhoneticString, 
-                        const PhoneticPortionVec& rPhoneticPortions) :
+                        const PortionVec& rPhoneticPortions) :
     maPhoneticPortions(rPhoneticPortions),
     maPhoneticString(rPhoneticString),
     mnFontIdx(nFontIdx),
     return maPhoneticString; 
 }
 
-const PhoneticPortionVec& ScPhonetic::GetPortions() const 
+const ScPhonetic::PortionVec& ScPhonetic::GetPortions() const 
 {
     return maPhoneticPortions; 
 }

File sc/source/core/tool/interpr4.cxx

         return;
 
     const String& rPhoneticString = aPhonetic.GetString();
-    PhoneticPortionVec portions = aPhonetic.GetPortions();
+    ScPhonetic::PortionVec portions = aPhonetic.GetPortions();
     sal_uInt16 nPortionCount = portions.size();
 
     String tmpString;
         sal_uInt16 pos = 0;
         for ( sal_uInt16 idx = 0; idx < nPortionCount; ++idx )
         {
-            const PhoneticPortion& portion = portions[idx];
+            const ScPhonetic::Portion& portion = portions[idx];
 
             // Get the end position in the phonetic text.
             sal_uInt16 nPhEndPos = idx < nPortionCount-1 ? portions[idx+1].mncpa : rPhoneticString.Len();

File sc/source/filter/excel/xestring.cxx

             rStrm << static_cast< sal_uInt16 > ( 0 );
         }
 
-        PhoneticPortionVec portions = maPhonetic.GetPortions();
+        ScPhonetic::PortionVec portions = maPhonetic.GetPortions();
         for ( sal_uInt16 idx = 0; idx < nPortions; ++idx)
         {
-            PhoneticPortion portion = portions[idx];
+            ScPhonetic::Portion portion = portions[idx];
             rStrm << portion.mncpa << portion.mncpm << portion.mnccm;
         }
     }

File sc/source/filter/excel/xistring.cxx

 
 void XclImpString::ReadPhoneticSettings( XclImpStream& rStrm, sal_uInt32 /*nExtInf*/ )
 {
-    PhoneticPortionVec xPortions;
+    ScPhonetic::PortionVec xPortions;
 
     rStrm.Ignore( 2 ); // Unknown indentifier 0001
 
     {
         sal_uInt16 ncpa, ncpm, nccm;
         rStrm >> ncpa >> ncpm >> nccm;
-        xPortions.push_back ( PhoneticPortion( ncpa, ncpm, nccm ) );
+        xPortions.push_back ( ScPhonetic::Portion( ncpa, ncpm, nccm ) );
     }
 
     maPhonetic = ScPhonetic ( nFontIdx, nAdditional, nRepeatedLength,

File sc/source/filter/xml/XMLTextPContext.cxx

     sal_uInt16 startIdx = aContent.getLength();
     sal_uInt16 endIdx = rBaseText.getLength();
 
-    PhoneticPortion portion( sOURubyText.getLength(), startIdx, endIdx );
+    ScPhonetic::Portion portion( sOURubyText.getLength(), startIdx, endIdx );
     sOURubyText.append( rRubyText );
     aPhoneticPortions.push_back( portion );
 

File sc/source/filter/xml/XMLTextPContext.hxx

 	USHORT						nPrefix;
 	sal_Bool					bIsOwn;
     rtl::OUStringBuffer         sOURubyText;
-    PhoneticPortionVec          aPhoneticPortions;
+    ScPhonetic::PortionVec          aPhoneticPortions;
 
 	const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
 	ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }

File sc/source/filter/xml/xmlcelli.cxx

 
     if ( pPhoneticText && pPhoneticText->getLength() )
     {
-        PhoneticPortionVec xPortions;
+        ScPhonetic::PortionVec xPortions;
         sal_uInt16 aKanaType = lcl_GetKanaType ( pPhoneticText );
         ScPhonetic aPhonetic ( 0, 0x30 | aKanaType , 0, *pPhoneticText, xPortions );
         pCell = new ScAsianStringCell( rString, aPhonetic );
                             ScDocument* pDoc = rXMLImport.GetDocument();
                             ScUnoConversion::FillScAddress( aScAddress, aCurrentPos );
                             ScBaseCell *pBaseCell = pDoc->GetCell( aScAddress );
-                            PhoneticPortionVec xPortions;
+                            ScPhonetic::PortionVec xPortions;
                             sal_uInt16 aKanaType = lcl_GetKanaType ( pOUPhoneticText );
                             ScPhonetic aPhonetic ( 0, 0x30 | aKanaType , 0, *pOUPhoneticText, xPortions );
                             ScBaseCell *pNewCell = new ScAsianEditCell( (const ScEditCell&) *pBaseCell, *pDoc, aPhonetic );

File sc/source/filter/xml/xmlexprt.cxx

 
 namespace {
 
-String GetOutputPhoneticData_Impl(ScDocument* pDoc, const ScAddress& aCellPos)
+void lcl_getPhoneticData(ScDocument* pDoc, const ScAddress& aCellPos, ScPhonetic& rPhonetic)
 {
-    String aVal;
-    if ( pDoc )
+    if (!pDoc)
+        return;
+
+    ScBaseCell* pCell = pDoc->GetCell(aCellPos);
+    if (!pCell)
+        return;
+
+    if (pCell->GetCellType() == CELLTYPE_STRING && static_cast<const ScStringCell*>(pCell)->HasPhonetic())
     {
-        ScBaseCell* pCell = pDoc->GetCell( aCellPos );
-        if ( pCell && pCell->GetCellType() == CELLTYPE_STRING &&
-             static_cast<const ScStringCell*>(pCell)->HasPhonetic() )
-        {
-            ScPhonetic aPhonetic;
-            static_cast<const ScAsianStringCell*>(pCell)->GetPhonetic(aPhonetic);
-            if ( !aPhonetic.IsEmpty() )
-                aVal = aPhonetic.GetString();
-        }
-        else if ( pCell && pCell->GetCellType() == CELLTYPE_EDIT && 
-                  static_cast<const ScEditCell*>(pCell)->HasPhonetic() )
-        {
-            ScPhonetic aPhonetic;
-            static_cast<const ScAsianEditCell*>(pCell)->GetPhonetic(aPhonetic);
-            if ( !aPhonetic.IsEmpty() )
-                aVal = aPhonetic.GetString();
-        }
+        static_cast<const ScAsianStringCell*>(pCell)->GetPhonetic(rPhonetic);
     }
-    return aVal;
+    else if (pCell->GetCellType() == CELLTYPE_EDIT && static_cast<const ScEditCell*>(pCell)->HasPhonetic())
+    {
+        static_cast<const ScAsianEditCell*>(pCell)->GetPhonetic(rPhonetic);
+    }
 }
 
 }
 
     rMyCell.sStringValue = ScCellObj::GetOutputString_Impl(pDoc, aPos);
     rMyCell.bHasStringValue = sal_True;
-    rMyCell.sPhoneticText = GetOutputPhoneticData_Impl(pDoc, aPos);
+    lcl_getPhoneticData(pDoc, aPos, rMyCell.aPhoneticData);
     rMyCell.bHasPhonetic = sal_True;
     return sal_True;
 }
 
 void ScXMLExport::WriteRubyText (ScMyCell& rMyCell)
 {
-    if ( !rMyCell.sPhoneticText.getLength() )
+    if (rMyCell.aPhoneticData.IsEmpty())
         return;
 
-    StartElement( XML_NAMESPACE_TEXT, XML_RUBY, sal_False);
-    StartElement( XML_NAMESPACE_TEXT, XML_RUBY_BASE, sal_False );
+    SvXMLElementExport aRubyElem(*this, XML_NAMESPACE_TEXT, XML_RUBY, sal_True, sal_False);
+    SvXMLElementExport aRubyBaseElem(*this, XML_NAMESPACE_TEXT, XML_RUBY_BASE, sal_True, sal_False);
     Characters( rMyCell.sStringValue );
-    EndElement( XML_NAMESPACE_TEXT, XML_RUBY_BASE, sal_False );
-    StartElement( XML_NAMESPACE_TEXT, XML_RUBY_TEXT, sal_False );
-    Characters( rMyCell.sPhoneticText );
-    EndElement( XML_NAMESPACE_TEXT, XML_RUBY_TEXT, sal_False );
-    EndElement( XML_NAMESPACE_TEXT, XML_RUBY, sal_False);
 }
 
 void ScXMLExport::WriteCell (ScMyCell& aCell)
             uno::Reference<text::XText> xText(xCurrentTableCellRange->getCellByPosition(aCell.aCellAddress.Column, aCell.aCellAddress.Row), uno::UNO_QUERY);
 			if ( xText.is())
 				GetTextParagraphExport()->exportText(xText, sal_False, sal_False);
-            if (GetCellText( aCell, aCellPos ) && aCell.sPhoneticText.getLength())
+            if (GetCellText( aCell, aCellPos ) && !aCell.aPhoneticData.IsEmpty())
                 WriteRubyText( aCell );
 		}
 		else
 			sal_Bool bPrevCharWasSpace(sal_True);
 	  		if (GetCellText(aCell, aCellPos))
             {
-                if ( aCell.sPhoneticText.getLength() )
+                if ( !aCell.aPhoneticData.IsEmpty() )
                     WriteRubyText( aCell );
                 else 
                     GetTextParagraphExport()->exportText( aCell.sStringValue, bPrevCharWasSpace );