// **************************************************************************** // // Function Name: RNumberDialog::GetSmartNumberSuffix // // Description: Return internationally correct suffix for given string // embedded number // // Returns: suffix // // Exceptions: None // // **************************************************************************** RMBCString RNumberDialog::GetSmartNumberSuffix( const RMBCString& rNumber ) { int nNumber = atoi( (LPCSZ)rNumber ); TpsAssert( nNumber >= 0 , "Number string invalid. Negative numbers not supported." ); TpsAssert( nNumber <= kMaxNumber, "Number string invalid. Too large."); TpsAssert( rNumber.GetStringLength() <= kMaxNumNumbers, "Number string too long" ); if( nNumber == 0 && rNumber.GetStringLength() > 1 ) { TpsAssertAlways( "Invalid number string." ); } // // Only interested in the last two digits of number (ie. Suffix for 12 is the // same as suffix for 112) int nMeaningfulDigits = atoi( (LPCSZ)rNumber ); if( rNumber.GetStringLength() > 2 ) { // If the number is three digits or greater, just get the last two digits.. char sDigitConvert[3]; //strncpy( sDigitConvert, (LPCSZ)rNumber[ rNumber.GetStringLength() - 2 ], 2 ); sDigitConvert[ 0 ] = rNumber[ rNumber.GetStringLength() - 2 ]; sDigitConvert[ 1 ] = rNumber[ rNumber.GetStringLength() - 1 ]; sDigitConvert[ 2 ] = 0; nMeaningfulDigits = atoi( sDigitConvert ); } // // To be safe for all languages we define suffixes for every number up to // 20, then just define suffixes for the second digit for numbers greater // than that. if( nMeaningfulDigits < kNumberOfSuffixesDefinedFromZero ) { /*!!!!!!!!!!!! NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ // Smart number ids from 0-19 MUST be sequential or the proper suffix will // NOT be used!!!!!! -MWH int nFirstSuffixInResource = IDS_SMARTNUM_SUFFIX_0; return ::GetResourceManager().GetResourceString( nFirstSuffixInResource + nMeaningfulDigits ); } else { // // Number is greater than 20, need to get last digit suffix RMBCString rLastDigit(""); rLastDigit += rNumber[rNumber.GetStringLength()-1]; int nLastDigit = atoi( (LPCSZ)rLastDigit ); /*!!!!!!!!!!!! NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ // Smart number two digit ids MUST be sequential or the proper suffix will // NOT be used!!!!!! -MWH int nFirst2DigitSuffixInResource = IDS_SMARTNUM_2DIGIT_SUFFIX_0; return ::GetResourceManager().GetResourceString( nFirst2DigitSuffixInResource + nLastDigit ); } }
// **************************************************************************** // // Function Name: RHLSpellCheckInterface::RHLSpellCheckInterface() // // Description: Replace the current word with the given replacement // // Returns: TRUE if sucessful // // Exceptions: None // // **************************************************************************** BOOLEAN RHLSpellCheckInterface::ReplaceWord( const RMBCString& original, const RMBCString& replacement ) { RMBCString newText; RMBCStringIterator iterator = m_Text.Start( ); RMBCStringIterator iteratorEnd = m_Text.End( ); // Empty the new string ( just to be paranoid ); newText.Empty( ); // Copy the text before the word int nLength = 0; while ( nLength++ < m_nWordStart ) { newText += (*iterator); ++iterator; } // add the replacement word newText += replacement; // skip over the original word iterator += original.GetStringLength( ); // add the remaining string while ( iterator != iteratorEnd ) { newText += (*iterator); ++iterator; } m_pDocument->SetHeadlineText( newText ); m_Text = newText; m_nWordEnd = m_nWordStart + replacement.GetStringLength(); // Invalidate the render cache TpsAssertIsObject( RComponentView, m_pDocument->GetActiveView( ) ); RComponentView* pView = static_cast< RComponentView* >( m_pDocument->GetActiveView( ) ); pView->InvalidateRenderCache( ); return TRUE; }
// **************************************************************************** // // Function Name: RNumberDialog::StripSmartNumber // // Description: Strip the smart number suffix if there is one. // // Returns: pointer to ContextData // // Exceptions: None // // **************************************************************************** // void RNumberDialog::StripSmartNumber( RMBCString& rNumber ) { char* pStrippedNumber = new char[ rNumber.GetStringLength() + 1 ]; try { strcpy( pStrippedNumber, (LPCSZ)rNumber ); for( int nIdx = 0; nIdx < rNumber.GetStringLength(); nIdx++ ) { if( !isdigit( pStrippedNumber[nIdx] ) ) { pStrippedNumber[nIdx] = 0; break; } } } catch( ... ) { delete [] pStrippedNumber; throw; } rNumber = RMBCString( pStrippedNumber ); delete [] pStrippedNumber; }
// **************************************************************************** // // Function Name: RMergeData::SaveAsFile( ) // // Description: Make this MergeData takes its values from a choosen file // // Returns: Nothing // // Exceptions: None // // **************************************************************************** // BOOLEAN RMergeData::SaveAsFile( ) { try { RMBCString fileName; #ifdef _WINDOWS RMBCString fileExtension; RMBCString fileFilter; ReturnFileExtension( fileExtension, TRUE ); ReturnFileFilter( fileFilter, TRUE ); CFileDialog dialog( FALSE, (LPCTSTR)fileExtension, NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, (LPCTSTR)fileFilter, NULL ); if ( dialog.DoModal( ) == IDCANCEL ) return FALSE; fileName = dialog.GetPathName( ); #else // MAC #endif // _WINDOWS if ( fileName.GetStringLength() > 0 ) { RMBCString oldFileName = m_FileName; m_FileName = fileName; if ( !SaveFile( ) ) { m_FileName = oldFileName; return FALSE; } } } catch( YException exception ) { ::ReportException( exception ); return FALSE; } catch( ... ) { ::ReportException( kUnknownError ); return FALSE; } return TRUE; }
// **************************************************************************** // // Function Name: ParseAndPutInListBox // // Description: Parses tokens out of passed in string, and loads tokens into listbox. // // Returns: void // // Exceptions: None // // **************************************************************************** void ParseAndPutInComboBox( RMBCString& rListToParse, CComboBox& cComboBox ) { char* pList = NULL; pList = new char[ rListToParse.GetStringLength() + 1 ]; try { cComboBox.ResetContent(); strcpy( pList, rListToParse ); char* pListItem = NULL; pListItem = strtok( pList, kListFieldSeperator ); while( pListItem ) { cComboBox.AddString( pListItem ); pListItem = strtok( NULL, kListFieldSeperator ); } } catch(...) { delete pList; throw; } delete pList; }