Whitespace cleanup only.
This commit is contained in:
@@ -111,7 +111,7 @@ AddSymlinkToPackage lib : libbe.so : liblocale.so ;
|
|||||||
AddFilesToPackage servers : $(SYSTEM_SERVERS) ;
|
AddFilesToPackage servers : $(SYSTEM_SERVERS) ;
|
||||||
|
|
||||||
# apps
|
# apps
|
||||||
AddFilesToPackage : runtime_loader Deskbar Tracker ;
|
AddFilesToPackage : runtime_loader Deskbar Tracker ;
|
||||||
AddFilesToPackage bin : $(SYSTEM_BIN) consoled ;
|
AddFilesToPackage bin : $(SYSTEM_BIN) consoled ;
|
||||||
AddFilesToPackage apps : $(SYSTEM_APPS) ;
|
AddFilesToPackage apps : $(SYSTEM_APPS) ;
|
||||||
AddFilesToPackage preferences : $(SYSTEM_PREFERENCES) ;
|
AddFilesToPackage preferences : $(SYSTEM_PREFERENCES) ;
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ BTranslationUtils::operator=(const BTranslationUtils &kUtils)
|
|||||||
//
|
//
|
||||||
// Preconditions:
|
// Preconditions:
|
||||||
//
|
//
|
||||||
// Parameters: kName, the name of the bitmap file or resource to
|
// Parameters: kName, the name of the bitmap file or resource to
|
||||||
// be returned
|
// be returned
|
||||||
// roster, BTranslatorRoster used to do the translation
|
// roster, BTranslatorRoster used to do the translation
|
||||||
//
|
//
|
||||||
@@ -84,11 +84,11 @@ BTranslationUtils::GetBitmap(const char *kName, BTranslatorRoster *roster)
|
|||||||
{
|
{
|
||||||
BBitmap *pBitmap = GetBitmapFile(kName, roster);
|
BBitmap *pBitmap = GetBitmapFile(kName, roster);
|
||||||
// Try loading a bitmap from the file named name
|
// Try loading a bitmap from the file named name
|
||||||
|
|
||||||
// Try loading the bitmap as an application resource
|
// Try loading the bitmap as an application resource
|
||||||
if (pBitmap == NULL)
|
if (pBitmap == NULL)
|
||||||
pBitmap = GetBitmap(B_TRANSLATOR_BITMAP, kName, roster);
|
pBitmap = GetBitmap(B_TRANSLATOR_BITMAP, kName, roster);
|
||||||
|
|
||||||
return pBitmap;
|
return pBitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ BTranslationUtils::GetBitmap(const char *kName, BTranslatorRoster *roster)
|
|||||||
// GetBitmap
|
// GetBitmap
|
||||||
//
|
//
|
||||||
// Returns a BBitmap object for the bitmap resource identified by
|
// Returns a BBitmap object for the bitmap resource identified by
|
||||||
// the type type with the resource id, id.
|
// the type type with the resource id, id.
|
||||||
// The user has to delete this object.
|
// The user has to delete this object.
|
||||||
//
|
//
|
||||||
// Preconditions:
|
// Preconditions:
|
||||||
@@ -119,20 +119,20 @@ BTranslationUtils::GetBitmap(uint32 type, int32 id, BTranslatorRoster *roster)
|
|||||||
// it belongs to the application
|
// it belongs to the application
|
||||||
if (pResources == NULL || pResources->HasResource(type, id) == false)
|
if (pResources == NULL || pResources->HasResource(type, id) == false)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// Load the bitmap resource from the application file
|
// Load the bitmap resource from the application file
|
||||||
// pRawData should be NULL if the resource is an
|
// pRawData should be NULL if the resource is an
|
||||||
// unknown type or not available
|
// unknown type or not available
|
||||||
size_t bitmapSize = 0;
|
size_t bitmapSize = 0;
|
||||||
const void *kpRawData = pResources->LoadResource(type, id, &bitmapSize);
|
const void *kpRawData = pResources->LoadResource(type, id, &bitmapSize);
|
||||||
if (kpRawData == NULL || bitmapSize == 0)
|
if (kpRawData == NULL || bitmapSize == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
BMemoryIO memio(kpRawData, bitmapSize);
|
BMemoryIO memio(kpRawData, bitmapSize);
|
||||||
// Put the pointer to the raw image data into a BMemoryIO object
|
// Put the pointer to the raw image data into a BMemoryIO object
|
||||||
// so that it can be used with BTranslatorRoster->Translate() in
|
// so that it can be used with BTranslatorRoster->Translate() in
|
||||||
// the GetBitmap(BPositionIO *, BTranslatorRoster *) function
|
// the GetBitmap(BPositionIO *, BTranslatorRoster *) function
|
||||||
|
|
||||||
return GetBitmap(&memio, roster);
|
return GetBitmap(&memio, roster);
|
||||||
// Translate the data in memio using the BTranslatorRoster roster
|
// Translate the data in memio using the BTranslatorRoster roster
|
||||||
}
|
}
|
||||||
@@ -141,7 +141,7 @@ BTranslationUtils::GetBitmap(uint32 type, int32 id, BTranslatorRoster *roster)
|
|||||||
// GetBitmap
|
// GetBitmap
|
||||||
//
|
//
|
||||||
// Returns a BBitmap object for the bitmap resource identified by
|
// Returns a BBitmap object for the bitmap resource identified by
|
||||||
// the type type with the resource name, kName.
|
// the type type with the resource name, kName.
|
||||||
// The user has to delete this object. Note that a resource type
|
// The user has to delete this object. Note that a resource type
|
||||||
// and name does not uniquely identify a resource in a file.
|
// and name does not uniquely identify a resource in a file.
|
||||||
//
|
//
|
||||||
@@ -166,17 +166,17 @@ BTranslationUtils::GetBitmap(uint32 type, const char *kName,
|
|||||||
// it belongs to the application
|
// it belongs to the application
|
||||||
if (pResources == NULL || pResources->HasResource(type, kName) == false)
|
if (pResources == NULL || pResources->HasResource(type, kName) == false)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// Load the bitmap resource from the application file
|
// Load the bitmap resource from the application file
|
||||||
size_t bitmapSize = 0;
|
size_t bitmapSize = 0;
|
||||||
const void *kpRawData = pResources->LoadResource(type, kName, &bitmapSize);
|
const void *kpRawData = pResources->LoadResource(type, kName, &bitmapSize);
|
||||||
if (kpRawData == NULL || bitmapSize == 0)
|
if (kpRawData == NULL || bitmapSize == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
BMemoryIO memio(kpRawData, bitmapSize);
|
BMemoryIO memio(kpRawData, bitmapSize);
|
||||||
// Put the pointer to the raw image data into a BMemoryIO object so
|
// Put the pointer to the raw image data into a BMemoryIO object so
|
||||||
// that it can be used with BTranslatorRoster->Translate()
|
// that it can be used with BTranslatorRoster->Translate()
|
||||||
|
|
||||||
return GetBitmap(&memio, roster);
|
return GetBitmap(&memio, roster);
|
||||||
// Translate the data in memio using the BTranslatorRoster roster
|
// Translate the data in memio using the BTranslatorRoster roster
|
||||||
}
|
}
|
||||||
@@ -203,7 +203,7 @@ BTranslationUtils::GetBitmapFile(const char *kName, BTranslatorRoster *roster)
|
|||||||
{
|
{
|
||||||
if (!be_app || !kName || kName[0] == '\0')
|
if (!be_app || !kName || kName[0] == '\0')
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
BPath path;
|
BPath path;
|
||||||
if (kName[0] != '/') {
|
if (kName[0] != '/') {
|
||||||
// If kName is a relative path, use the path of the application's
|
// If kName is a relative path, use the path of the application's
|
||||||
@@ -221,7 +221,7 @@ BTranslationUtils::GetBitmapFile(const char *kName, BTranslatorRoster *roster)
|
|||||||
|
|
||||||
} else if (path.SetTo(kName) != B_OK)
|
} else if (path.SetTo(kName) != B_OK)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
BFile bitmapFile(path.Path(), B_READ_ONLY);
|
BFile bitmapFile(path.Path(), B_READ_ONLY);
|
||||||
if (bitmapFile.InitCheck() != B_OK)
|
if (bitmapFile.InitCheck() != B_OK)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -281,8 +281,8 @@ BTranslationUtils::GetBitmap(BPositionIO *stream, BTranslatorRoster *roster)
|
|||||||
{
|
{
|
||||||
if (stream == NULL)
|
if (stream == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// Use default Translator if none is specified
|
// Use default Translator if none is specified
|
||||||
if (roster == NULL) {
|
if (roster == NULL) {
|
||||||
roster = BTranslatorRoster::Default();
|
roster = BTranslatorRoster::Default();
|
||||||
if (roster == NULL)
|
if (roster == NULL)
|
||||||
@@ -295,7 +295,7 @@ BTranslationUtils::GetBitmap(BPositionIO *stream, BTranslatorRoster *roster)
|
|||||||
if (roster->Translate(stream, NULL, NULL, &bitmapStream,
|
if (roster->Translate(stream, NULL, NULL, &bitmapStream,
|
||||||
B_TRANSLATOR_BITMAP) < B_OK)
|
B_TRANSLATOR_BITMAP) < B_OK)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// Detach the BBitmap from the BBitmapStream so the user
|
// Detach the BBitmap from the BBitmapStream so the user
|
||||||
// of this function can do what they please with it.
|
// of this function can do what they please with it.
|
||||||
BBitmap *pBitmap = NULL;
|
BBitmap *pBitmap = NULL;
|
||||||
@@ -307,13 +307,13 @@ BTranslationUtils::GetBitmap(BPositionIO *stream, BTranslatorRoster *roster)
|
|||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
This function translates the styled text in fromStream and
|
This function translates the styled text in fromStream and
|
||||||
inserts it at the end of the text in intoView, using the
|
inserts it at the end of the text in intoView, using the
|
||||||
BTranslatorRoster *roster to do the translation. The structs
|
BTranslatorRoster *roster to do the translation. The structs
|
||||||
that make it possible to work with the translated data are
|
that make it possible to work with the translated data are
|
||||||
defined in
|
defined in
|
||||||
/boot/develop/headers/be/translation/TranslatorFormats.h
|
/boot/develop/headers/be/translation/TranslatorFormats.h
|
||||||
|
|
||||||
\param source the stream with the styled text
|
\param source the stream with the styled text
|
||||||
\param intoView the view where the test will be inserted
|
\param intoView the view where the test will be inserted
|
||||||
roster, BTranslatorRoster used to do the translation
|
roster, BTranslatorRoster used to do the translation
|
||||||
@@ -330,7 +330,7 @@ BTranslationUtils::GetStyledText(BPositionIO* source, BTextView* intoView,
|
|||||||
if (source == NULL || intoView == NULL)
|
if (source == NULL || intoView == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
// Use default Translator if none is specified
|
// Use default Translator if none is specified
|
||||||
if (roster == NULL) {
|
if (roster == NULL) {
|
||||||
roster = BTranslatorRoster::Default();
|
roster = BTranslatorRoster::Default();
|
||||||
if (roster == NULL)
|
if (roster == NULL)
|
||||||
@@ -374,7 +374,7 @@ BTranslationUtils::GetStyledText(BPositionIO* source, BTextView* intoView,
|
|||||||
if (mallocIO.BufferLength() < offset + kTextHeaderSize)
|
if (mallocIO.BufferLength() < offset + kTextHeaderSize)
|
||||||
return B_BAD_DATA;
|
return B_BAD_DATA;
|
||||||
|
|
||||||
TranslatorStyledTextTextHeader textHeader =
|
TranslatorStyledTextTextHeader textHeader =
|
||||||
*(const TranslatorStyledTextTextHeader *)(buffer + offset);
|
*(const TranslatorStyledTextTextHeader *)(buffer + offset);
|
||||||
|
|
||||||
// convert the stm_header.header struct to the host format
|
// convert the stm_header.header struct to the host format
|
||||||
@@ -402,7 +402,7 @@ BTranslationUtils::GetStyledText(BPositionIO* source, BTextView* intoView,
|
|||||||
const size_t kStyleHeaderSize =
|
const size_t kStyleHeaderSize =
|
||||||
sizeof(TranslatorStyledTextStyleHeader);
|
sizeof(TranslatorStyledTextStyleHeader);
|
||||||
if (mallocIO.BufferLength() >= offset + kStyleHeaderSize) {
|
if (mallocIO.BufferLength() >= offset + kStyleHeaderSize) {
|
||||||
TranslatorStyledTextStyleHeader styleHeader =
|
TranslatorStyledTextStyleHeader styleHeader =
|
||||||
*(reinterpret_cast<const TranslatorStyledTextStyleHeader *>(buffer + offset));
|
*(reinterpret_cast<const TranslatorStyledTextStyleHeader *>(buffer + offset));
|
||||||
swap_data(B_UINT32_TYPE, &styleHeader.header, kRecordHeaderSize, B_SWAP_BENDIAN_TO_HOST);
|
swap_data(B_UINT32_TYPE, &styleHeader.header, kRecordHeaderSize, B_SWAP_BENDIAN_TO_HOST);
|
||||||
swap_data(B_UINT32_TYPE, &styleHeader.apply_offset, sizeof(uint32), B_SWAP_BENDIAN_TO_HOST);
|
swap_data(B_UINT32_TYPE, &styleHeader.apply_offset, sizeof(uint32), B_SWAP_BENDIAN_TO_HOST);
|
||||||
@@ -452,11 +452,11 @@ BTranslationUtils::GetStyledText(BPositionIO* source, BTextView* intoView,
|
|||||||
plain text data to the file, but puts the styled text data in
|
plain text data to the file, but puts the styled text data in
|
||||||
the "styles" attribute. In other words, this function writes
|
the "styles" attribute. In other words, this function writes
|
||||||
styled text data to files in a manner that isn't human readable.
|
styled text data to files in a manner that isn't human readable.
|
||||||
|
|
||||||
So, if you want to write styled text
|
So, if you want to write styled text
|
||||||
data to a file, and you want it to behave the way StyledEdit does,
|
data to a file, and you want it to behave the way StyledEdit does,
|
||||||
you want to use the BTranslationUtils::WriteStyledEditFile() function.
|
you want to use the BTranslationUtils::WriteStyledEditFile() function.
|
||||||
|
|
||||||
\param fromView, the view with the styled text in it
|
\param fromView, the view with the styled text in it
|
||||||
\param intoStream, the stream where the styled text is put
|
\param intoStream, the stream where the styled text is put
|
||||||
roster, not used
|
roster, not used
|
||||||
@@ -471,20 +471,20 @@ BTranslationUtils::PutStyledText(BTextView *fromView, BPositionIO *intoStream,
|
|||||||
{
|
{
|
||||||
if (fromView == NULL || intoStream == NULL)
|
if (fromView == NULL || intoStream == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
int32 textLength = fromView->TextLength();
|
int32 textLength = fromView->TextLength();
|
||||||
if (textLength < 0)
|
if (textLength < 0)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
const char *pTextData = fromView->Text();
|
const char *pTextData = fromView->Text();
|
||||||
// its OK if the result of fromView->Text() is NULL
|
// its OK if the result of fromView->Text() is NULL
|
||||||
|
|
||||||
int32 runArrayLength = 0;
|
int32 runArrayLength = 0;
|
||||||
text_run_array *runArray = fromView->RunArray(0, textLength,
|
text_run_array *runArray = fromView->RunArray(0, textLength,
|
||||||
&runArrayLength);
|
&runArrayLength);
|
||||||
if (runArray == NULL)
|
if (runArray == NULL)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
int32 flatRunArrayLength = 0;
|
int32 flatRunArrayLength = 0;
|
||||||
void *pflatRunArray =
|
void *pflatRunArray =
|
||||||
BTextView::FlattenRunArray(runArray, &flatRunArrayLength);
|
BTextView::FlattenRunArray(runArray, &flatRunArrayLength);
|
||||||
@@ -496,13 +496,13 @@ BTranslationUtils::PutStyledText(BTextView *fromView, BPositionIO *intoStream,
|
|||||||
#endif
|
#endif
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rather than use a goto, I put a whole bunch of code that
|
// Rather than use a goto, I put a whole bunch of code that
|
||||||
// could error out inside of a loop, and break out of the loop
|
// could error out inside of a loop, and break out of the loop
|
||||||
// if there is an error.
|
// if there is an error.
|
||||||
|
|
||||||
// This block of code is where I do all of the writing of the
|
// This block of code is where I do all of the writing of the
|
||||||
// data to the stream. I've gathered all of the data that I
|
// data to the stream. I've gathered all of the data that I
|
||||||
// need at this point.
|
// need at this point.
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
while (!ok) {
|
while (!ok) {
|
||||||
@@ -513,7 +513,7 @@ BTranslationUtils::PutStyledText(BTextView *fromView, BPositionIO *intoStream,
|
|||||||
stm_header.header.header_size = kStreamHeaderSize;
|
stm_header.header.header_size = kStreamHeaderSize;
|
||||||
stm_header.header.data_size = 0;
|
stm_header.header.data_size = 0;
|
||||||
stm_header.version = 100;
|
stm_header.version = 100;
|
||||||
|
|
||||||
// convert the stm_header.header struct to the host format
|
// convert the stm_header.header struct to the host format
|
||||||
const size_t kRecordHeaderSize =
|
const size_t kRecordHeaderSize =
|
||||||
sizeof(TranslatorStyledTextRecordHeader);
|
sizeof(TranslatorStyledTextRecordHeader);
|
||||||
@@ -631,7 +631,7 @@ BTranslationUtils::WriteStyledEditFile(BTextView* view, BFile* file, const char
|
|||||||
// move to the start of the file if not already there
|
// move to the start of the file if not already there
|
||||||
status_t status = file->Seek(0, SEEK_SET);
|
status_t status = file->Seek(0, SEEK_SET);
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
const BCharacterSet* characterSet = NULL;
|
const BCharacterSet* characterSet = NULL;
|
||||||
if (encoding != NULL && strcmp(encoding, ""))
|
if (encoding != NULL && strcmp(encoding, ""))
|
||||||
@@ -760,17 +760,17 @@ BMessage *
|
|||||||
BTranslationUtils::GetDefaultSettings(translator_id forTranslator,
|
BTranslationUtils::GetDefaultSettings(translator_id forTranslator,
|
||||||
BTranslatorRoster *roster)
|
BTranslatorRoster *roster)
|
||||||
{
|
{
|
||||||
// Use default Translator if none is specified
|
// Use default Translator if none is specified
|
||||||
if (roster == NULL) {
|
if (roster == NULL) {
|
||||||
roster = BTranslatorRoster::Default();
|
roster = BTranslatorRoster::Default();
|
||||||
if (roster == NULL)
|
if (roster == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
BMessage *message = new BMessage();
|
BMessage *message = new BMessage();
|
||||||
if (message == NULL)
|
if (message == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
status_t result = roster->GetConfigurationMessage(forTranslator, message);
|
status_t result = roster->GetConfigurationMessage(forTranslator, message);
|
||||||
if (result != B_OK && result != B_NO_TRANSLATOR) {
|
if (result != B_OK && result != B_NO_TRANSLATOR) {
|
||||||
// Be's version seems to just pass an empty BMessage
|
// Be's version seems to just pass an empty BMessage
|
||||||
@@ -786,7 +786,7 @@ BTranslationUtils::GetDefaultSettings(translator_id forTranslator,
|
|||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// GetDefaultSettings
|
// GetDefaultSettings
|
||||||
//
|
//
|
||||||
// Attempts to find the translator settings for
|
// Attempts to find the translator settings for
|
||||||
// the translator named kTranslatorName with a version of
|
// the translator named kTranslatorName with a version of
|
||||||
// translatorVersion.
|
// translatorVersion.
|
||||||
//
|
//
|
||||||
@@ -827,11 +827,11 @@ BTranslationUtils::GetDefaultSettings(const char *kTranslatorName,
|
|||||||
if (currentTranVersion == translatorVersion
|
if (currentTranVersion == translatorVersion
|
||||||
&& strcmp(currentTranName, kTranslatorName) == 0) {
|
&& strcmp(currentTranName, kTranslatorName) == 0) {
|
||||||
pMessage = GetDefaultSettings(translators[i], roster);
|
pMessage = GetDefaultSettings(translators[i], roster);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] translators;
|
delete[] translators;
|
||||||
return pMessage;
|
return pMessage;
|
||||||
}
|
}
|
||||||
@@ -864,7 +864,7 @@ BTranslationUtils::GetDefaultSettings(const char *kTranslatorName,
|
|||||||
// output format id in the menuitem
|
// output format id in the menuitem
|
||||||
// roster, BTranslatorRoster used to find translators
|
// roster, BTranslatorRoster used to find translators
|
||||||
// if NULL, the default translators are used
|
// if NULL, the default translators are used
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Postconditions:
|
// Postconditions:
|
||||||
//
|
//
|
||||||
@@ -879,7 +879,7 @@ BTranslationUtils::AddTranslationItems(BMenu *intoMenu, uint32 fromType,
|
|||||||
{
|
{
|
||||||
if (!intoMenu)
|
if (!intoMenu)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
if (!roster)
|
if (!roster)
|
||||||
roster = BTranslatorRoster::Default();
|
roster = BTranslatorRoster::Default();
|
||||||
|
|
||||||
@@ -914,7 +914,7 @@ BTranslationUtils::AddTranslationItems(BMenu *intoMenu, uint32 fromType,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Get supported output formats
|
// Get supported output formats
|
||||||
err = roster->GetOutputFormats(ids[tix], &formats, &numFormats);
|
err = roster->GetOutputFormats(ids[tix], &formats, &numFormats);
|
||||||
if (err == B_OK) {
|
if (err == B_OK) {
|
||||||
for (int oix = 0; oix < numFormats; oix++) {
|
for (int oix = 0; oix < numFormats; oix++) {
|
||||||
if (formats[oix].type != fromType) {
|
if (formats[oix].type != fromType) {
|
||||||
|
|||||||
Reference in New Issue
Block a user